anni anni - 3 days ago 7
ASP.NET (C#) Question

How to send mail using C# with html format

hello how to take reviews and rating from mail in c#?How to use html format for gmail.i have given link to review when i click on it it redirect me to next page that is Mail.aspx. so how can i send my rating and mail.aspx file in mail and i want my result to be store in database.

Answer

Setting isBodyHtml to true allows you to use HTML tags in the message body:

SmtpClient sc = new SmtpClient("mail address");
MailMessage msg = null;

try
{
msg = new MailMessage("xxxx@gmail.com",
    "yyyy@gmail.com", "Message from PSSP System",
    "This email sent by the PSSP system<br />" +
    "<b>this is bold text!</b>");

    msg.IsBodyHtml = true;

     sc.Send(msg);
}

catch (Exception ex)
{
    throw ex;
}

finally
{
    if (msg != null)
    {
        msg.Dispose();
    }
}

Use msg.IsBodyHtml = true;

Comments