Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Can help me make function send mail with content html tag using asp.net C# ?
Posted
Comments
[no name] 23-Sep-12 21:08pm    
Sure
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.
--SA
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    
Sure.
--SA

Click there: html mail in c#[^]
 
Share this answer
 
Comments
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.
--SA
pasztorpisti 24-Sep-12 5:20am    
Thank you!
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"


—SA
 
Share this answer
 
Comments
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,
--SA
You can send mail with this library.
http://higlabo.codeplex.com/[^]

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 = "my_address@mail.com";
mg.To.Add(new MailAddress("address@mail.com"));
//Send by HTML format
SmtpContent ct = new SmtpContent();
ct.LoadHtml("<html><head></head><body>......</body></html>");
mg.Contents.Add(ct);

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;
}
 
Share this answer
 

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