Click here to Skip to main content
12,768,041 members (43,581 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET4
Can help me make function send mail with content html tag using C# ?
Posted 23-Sep-12 16:05pm
Wes Aday 23-Sep-12 21:08pm
private void SendMail()
// Your code here
pasztorpisti 23-Sep-12 21:13pm
Is posting such a trivial question here easier than typing it into google???
Sergey Alexandrovich Kryukov 23-Sep-12 23:17pm
But there is no a trivial answer so far. :-) I agree though.
pasztorpisti 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 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 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 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 24-Sep-12 5:21am
+5, often the only missed setting in mime when the html mail "doesn't work"
Sergey Alexandrovich Kryukov 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
Top Experts
Last 24hrsThis month

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