Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: HTML C#4.0
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;
            try
            {
                MailAddress fromAddress = new MailAddress(from);
                message.From = fromAddress;
                message.To.Add(toList);
                if (ccList != null && ccList != string.Empty)
                    message.CC.Add(ccList);
                message.Subject = subject;
                message.IsBodyHtml = true;
                message.Body = body;
                
                smtpClient.Host = "smtp.compName.org";  
                smtpClient.Port = 587;
                smtpClient.EnableSsl = false;
                smtpClient.UseDefaultCredentials = true;
                smtpClient.Credentials = new System.Net.NetworkCredential(UserName,Password);
                smtpClient.Send(message);
                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.
 
Regards,
Avinash
Posted 21-Mar-13 0:35am
Edited 21-Mar-13 0:36am
v2
Comments
Prasad Khandekar at 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 at 21-Mar-13 6:01am
   
Thank you Prasad , I will confirm with the service provider.

1 solution

Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 OriginalGriff 120
3 PIEBALDconsult 110
4 BillWoodruff 85
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 22 Jun 2013
Copyright © CodeProject, 1999-2014
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