Click here to Skip to main content
13,046,281 members (85,299 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi All,

I am having an send email functionality in c# application.
Following is the code I am using to send email -

public static bool SendMail(string toList, string from, string ccList, string subject, string body)
           bool flag = false;
           MailMessage message = new MailMessage();
           SmtpClient smtpClient = new SmtpClient();
           string msg = string.Empty;
               MailAddress fromAddress = new MailAddress(from);
               message.From = fromAddress;
               if (ccList != null && ccList != string.Empty)
               message.Subject = subject;
               message.IsBodyHtml = true;
               message.Body = body;

               smtpClient.Host = "";
               smtpClient.Port = 587;
               smtpClient.EnableSsl = false;
               smtpClient.UseDefaultCredentials = true;
               smtpClient.Credentials = new System.Net.NetworkCredential(UserName,Password);
               flag = true;

           catch (Exception ex)
               msg = ex.Message;

           return flag;

I am using the same function from more than 8 months. Suddenly what happens I didn't understand.

I am not getting any emails from my applications. It has log entries - Mail sent successfully.
There is no any exception.

From above code I have commented message.IsBodyHtml = true; this line and I am getting emails but its html code.

What is the problem I am not understanding!!!
I am using network solutions service to send email.

Please suggest , ASAP.

Thanks for your suggestions in advance.

Posted 20-Mar-13 23:35pm
Updated 20-Mar-13 23:36pm
Prasad Khandekar 21-Mar-13 5:57am
As per documentation You need to set IsBodyHtml to true if you want to send HTML emails. If you are sending plain text emails then you will not require it. In your case since your code was working initially it might be relate to your mail server setting. Please contact the mail server administrator and see if HTML mail option is blocked.
Avinash6474 21-Mar-13 6:01am
Thank you Prasad , I will confirm with the service provider.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The problem with the service provider which I am using, after talking with them came to know that the web mail server was down , no problem with send mail functionality.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 22 Jun 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100