Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET4.0
Can help me make function send mail with content html tag using C# ?
Posted 23-Sep-12 15:05pm
Wes Aday at 23-Sep-12 21:08pm
private void SendMail()
// Your code here
pasztorpisti at 23-Sep-12 21:13pm
Is posting such a trivial question here easier than typing it into google???
Sergey Alexandrovich Kryukov at 23-Sep-12 23:17pm
But there is no a trivial answer so far. :-) I agree though.
pasztorpisti at 24-Sep-12 5:20am
It depends on what the OP wants. If its just sending a html mail without knowing the details then my comment is totally legitimate because you can find the answer to such frequently used functionality anywhere. If we speak of the process of mime encoding and mime format and related libraries to deal with it, then its a bit more complicated.
Sergey Alexandrovich Kryukov at 24-Sep-12 18:41pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Click there: html mail in c#[^]
Sergey Alexandrovich Kryukov at 23-Sep-12 23:24pm
My 5. Before I saw this post, I added a short answer with just a hint on the main thing -- please see.
pasztorpisti at 24-Sep-12 5:20am
Thank you!
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Just a hint: the e-mail should have "Content-Type: text/html"; for example, you can have one of the header lines
Content-Type: text/html; charset="utf-8"
pasztorpisti at 24-Sep-12 5:21am
+5, often the only missed setting in mime when the html mail "doesn't work"
Sergey Alexandrovich Kryukov at 24-Sep-12 12:24pm
Exactly, that's why I only provided a hint, but a key one.
Thank you,
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

You can send mail with this library.[^]
SmtpClient cl = new SmtpClient();
cl.ServerName = "your server name";
cl.Port = 25;
cl.Ssl = false;
SmtpMessage mg = new SmtpMessage();
mg.Subject = "Html mail test";
mg.From = "";
mg.To.Add(new MailAddress(""));
//Send by HTML format
SmtpContent ct = new SmtpContent();
var rs = cl.SendMail(mg);
//Check mail was sent or not
if (rs.SendSuccessfull == false)
    //You can get information about send mail is success or error reason
    var resultState = rs.State;

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 353
1 OriginalGriff 304
2 George Jonsson 258
3 Shemeemsha RA 138
4 Animesh Datta 130
0 OriginalGriff 5,985
1 Sergey Alexandrovich Kryukov 5,341
2 CPallini 4,760
3 George Jonsson 3,400
4 Gihan Liyanage 2,522

Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 23 Sep 2012
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