I am using the following codes for users to send me a quote to my email.
using System.Net.Mail;
MailMessage mail = new MailMessage();
mail.From = new MailAddress(Email.Text);
mail.To.Add("my yahoo email");
mail.Subject = "Requested Quote From my site";
mail.Body = "<br /><b>Primary project type:</b> " + ProjectTypeRadio.SelectedItem.Text + "<br /><b>Interested In:</b> " + InterestedCheck + "<br /><br /><br /><br /><b>PRODUCT DETAILS:</b><hr />" + Electric + HotWater + PoolHeating + SpaceHeating + "<br /> + "<br /><b>Message:</b><br /><hr /><br />" + txtMsg.Text + "<br /><br />";
SmtpClient smtp = new SmtpClient("smtp.mail.yahoo.com");
smtp.Send(mail);
Response.Redirect("Thanks.aspx");
Web.Config
<system.net>
<mailSettings>
<smtp>
<network host="smtp.mail.yahoo.com" port="995" userName="my yahoo email" password="Password" />
</smtp>
</mailSettings>
PROBLEM:
I am recieving the mail in my yahoo account but the message is not formated instead its showing all the HTML tags i.e.
Can anyone please check my code and point my mistake or guide me a solution, it will be a big favor, thanks.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You can set mail.IsBodyHTML = true
Also, depending on what you’re sending you may want to use AlternateViews to send both plain text and text/html variations.
Method 2
you must set BodyFormat
mail.BodyFormat = System.Web.Mail.MailFormat.Html;
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0