I keep getting the following error when I run this code. what is wrong with the code.
Error:
An invalid character was found in the mail header: '@'.
string bmsg = "<h3>" + txtFirstName.Text + " " + txtLastName.Text + "</h3>";
bmsg += "<p>This is your EPIC IPCST Conference Ticket Number <strong>" + lbInvoiceNumber.Text + "</strong> please keep this for your records";
string pt = "mypw";
[b]string cr = "my@domain.com";[/b]
MailMessage mm = new MailMessage(cr, emc);
mm.Subject = "2015 Conference Ticket";
mm.Body = bmsg;
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtpout.secureserver.net";
smtp.EnableSsl = false;
NetworkCredential NetworkCred = new NetworkCredential(cr, pt);
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 80;
smtp.Send(mm);
Open in new window
ERROR:
An invalid character was found in the mail header: '@'.
Line 401 is where the error is coming form.
string cr = "my@domain.com";
Stack:
Line 400: string pt = "mypw";
Line 401: string cr = "my@domain.com";
Line 402: MailMessage mm = new MailMessage(cr, emc);
Open in new window
Thank you.
MailMessage mm = new MailMessage(cr, emc);
what is EMC?
if you take out the cr and hardcode the string directly into it do you still get the error?
EG:
MailMessage mm = new MailMessage("my@domain.com