Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have write the code as

HTML
<body='&lt;html><table style="width:100%;border:solid 2px black"><tr style=" border:solid 2px black"><td colspan='6'>Venue Booking Report For Date: 18/05/2013</td></tr><tr style=" border:solid 2px black"><td><b>Time From</b></td><td><b>Time To</b></td><td><b>Location</b></td><td><b>Booked By</b></td><td><b>Description</b></td><td><b>Facilities Required</b></td></tr><tr><td>08:30 AM</td><td>09:00 AM</td><td>T-3 Disscussion Room II (3rd Floor)</td><td>Vikas Chandok</td><td>For Students - Victim Assistance Programme</td><td>Water</td></tr><tr><td>08:30 AM</td><td>05:30 PM</td><td>T-3 Conference Room (2nd Floor)</td><td>Mandeep Kaur</td><td>Centralized Evaluation Centre</td><td></td></tr></table>&lt;/html>'

C#
MailMessage message = new MailMessage();
SmtpClient client = new SmtpClient();
try
{
message.From = new MailAddress(fromemail, fromname);
message.Subject = subject;

message.Body = body;
message.IsBodyHtml = true;
message.To.Add(new MailAddress(to));
if (cc != "")
{
    foreach (string str in cc.Split(new char[] { ',' }))
    {
        message.CC.Add(new MailAddress(str.Trim()));
    }
}
if (bcc != "")
{
    foreach (string str2 in bcc.Split(new char[] { ','  }))
    {
        message.Bcc.Add(new MailAddress(str2.Trim()));
    }
}
client.Host = server;
client.EnableSsl = true;
NetworkCredential credential = new NetworkCredential
{
    UserName = new MailAddress(fromemail, fromname).Address,
    Password = frompwd
};
client.UseDefaultCredentials = true;
client.Credentials = credential;
client.Port = 0x24b;
client.Send(message);

Now the problem is that some time mail received as html format and some time text format
when multiple mail receiver are there in cc and bcc then it shows to some receiver as text format. i have tried with gmail sender and receiver and outlook sender and receiver.
Posted
Updated 23-May-13 3:33am
v2
Comments
[no name] 23-May-13 9:09am    
AFAIK, that is dependent on the email client. Does not have anything to do with your code.
Zoltán Zörgő 23-May-13 9:36am    
Agree.
Aarti Meswania 23-May-13 9:36am    
right :)
5!+
ZurdoDev 23-May-13 10:59am    
Correct. Post as solution, say I.
Aarti Meswania 23-May-13 9:35am    
ThePhantomUpvoter is right
there isn't any issue in your code :)

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900