Hi, I'm putting together a script to send out a preview html mail to hotmail etc, and I utlising an existing script - I'm new to c# so this is as much a learning expereince forme too.
The problem is I have made a few ammends, and it's fine up to the point I drop HTML source into the comments box - it then fails the sending.
I have looked into it and tried changing the new MailMessage(); to new MailDefinition(); and also adding in faqMsg.IsBodyHtml = true; but it's still failing. it's fine just on regular text. Any thoughts what I need to look into ?
SmtpClient smtpCli = new SmtpClient("localhost");
MailMessage faqMsg = new MailMessage();
//MailDefinition faqMsg = new MailDefinition();
//faqMsg.BodyFileName = "email.htm";
//faqMsg.IsBodyHtml = true;
faqMsg.From = new MailAddress("");
faqMsg.To.Add("");
faqMsg.Subject = "Mail test :" + subject.Text;
//Plain Text part
AlternateView plainView = AlternateView.CreateAlternateViewFromString("Enquiry Type:" + enquirytype.SelectedValue + "\r\nFrom:" + "\r\nEmail:" + email.Text + "\r\n\r\nComments\r\n" + comments.Text + "\r\n[EOF]", null, "text/plain");
//HTML part
AlternateView htmlView = AlternateView.CreateAlternateViewFromString("<strong>Enquiry Type:</strong>" + enquirytype.SelectedValue + "<br><br><strong>Email:</strong>" + email.Text + "<br><br><hr><br><strong>Comments</strong><br>" + HttpUtility.HtmlEncode(comments.Text) + "<br>EOF", null, "text/html");
faqMsg.AlternateViews.Add(plainView);
faqMsg.AlternateViews.Add(htmlView);
//Add Header Markers
faqMsg.Headers.Add("X-Company", "");
faqMsg.Headers.Add("X-Location", "");
faqMsg.Headers.Add("X-Brand", "");
smtpCli.Send(faqMsg);
lbReport.Text = "Your Message was Sent";
//Response.Redirect("email-thanks.aspx");