I am sending an email, when I add a team, but I am receiving the following error:
"The specified string is not in the form required for an e-mail address"
protected void SendAddTeamMail()
{
var fromAddress = "servicedesk@admedcorp.com";
var toAddress = EmailLabel.Text.ToString();
var toAddress2 = AddTeamLabelRequestor.Text.ToString();
var toAddress3 = AddTeamLabelAccurint.Text.ToString();
var toAddress4 = AddTeamLabelAccurintManager.Text.ToString();
const string fromPassword = "Password";
string subject = TitleLabel.Text.ToString();
string body = "Email: " + EmailLabel.Text + "\n";
body += "Accurint Number: " + IdLabel.Text + "\n";
body += "Accurint Status: " + StatusLabel.Text + "\n";
body += "Title: " + TitleLabel.Text + "\n";
body += "Description: " + DescriptionLabel.Text + "\n";
body += "Team:" + AddTeamLabelRequestor.Text + AddTeamLabelAccurint.Text + AddTeamLabelAccurintManager + "\n";
body += "Click the Following Link: " + HttpContext.Current.Request.Url.AbsoluteUri.Substring(0, HttpContext.Current.Request.Url.AbsoluteUri.Length - 9) + "MyTickets.aspx";
// smtp settings
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "mail.admedcorp.com";
smtp.Port = 25;
smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
}
// Passing values to smtp object
smtp.Send(fromAddress, toAddress, subject, body);
.aspx
<table>
<tbody>
<tr>
<td>Requestor:</td>
<td></td>
<td><asp:Label ID="AddTeamLabelRequestor" runat="server" ForeColor="Red"></asp:Label></td>
<td></td>
</tr>
<tr>
<td>Accurint: </td>
<td></td>
<td><asp:Label ID="AddTeamLabelAccurint" runat="server" ForeColor="Red"></asp:Label></td>
<td></td>
</tr>
<tr>
<td>Accurint Manager: </td>
<td></td>
<td><asp:Label ID="AddTeamLabelAccurintManager" runat="server" ForeColor="Red"></asp:Label></td>
<td></td>
</tr>
</tbody>
</table>
<p> </p>
<p>
<asp:Button ID="AddTeamButton" Cssclass="btn btn-default" runat="server" Text="Add Team" OnClick="AddTeamButton_Click" />
</p>