Click here to Skip to main content
15,906,333 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

In my C# application I want to send the email to customers with embeded HTML Table. How to do this one. Can any one help me to solve this problem. Here is the model I need:

Dear Customer,

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx



XXXXXXXXXX XXXXXXXXXX
xxxxx xxxxxx
xxxxx xxxxxx //Like this table
xxxxx xxxxxxx
xxxxxx xxxxxxxxx

Thanks

xxxxxx



Thanks in Advance
Posted

You can create body using HTML tags
C#
string body = "You have received a status update from " + Session["name"].ToString() + ", Department : " + Session["deptt"].ToString() + "  ,with reference to Assignment ID: " + lblassno.Text + " /Task ID: " + taskid + ". Kindly login TMS on Intranet Portal to view the details.";
        body += "<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><span style="mso-bidi-font-style:normal;font-style: italic;font-size: small;">This is a System generated message,";
        body += "kindly do not reply to this.<o:p xmlns:o="#unknown"></o:p></span>";


and send mail
C#
MailMessage m = new MailMessage("senderid", To);
                m.Subject = Subject;
                m.Body = Body;
                m.IsBodyHtml = true;
                m.From = new MailAddress(From);

                m.To.Add(new MailAddress(To));
                SmtpClient smtp = new SmtpClient();
                smtp.Host = "mail.google.com";
              
                NetworkCredential authinfo = new NetworkCredential("seder@gmail.com", "pass123");
                smtp.UseDefaultCredentials = false;
                smtp.Credentials = authinfo;
                smtp.Send(m);
 
Share this answer
 
Please see my answer to the related question:
Sending HTML attachment with images[^].

Actually, it answers a more general question: how to send multi-part e-mail with HTML part and graphics parts, and reference images in an HTML part. I think it's good to know, too.

—SA
 
Share this answer
 
Comments
ProEnggSoft 20-Mar-12 0:19am    
Good solution. 5!
Sergey Alexandrovich Kryukov 20-Mar-12 1:44am    
Thank you.
--SA

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