Click here to Skip to main content
Rate this: bad
good
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 asp.net C# ?
Posted 23-Sep-12 15:05pm
huynhpa647
Comments
Wes Aday at 23-Sep-12 21:08pm
   
Sure
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.
--SA
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
   
Sure.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Click there: html mail in c#[^]
  Permalink  
Comments
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.
--SA
pasztorpisti at 24-Sep-12 5:20am
   
Thank you!
Rate this: bad
good
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"
 
—SA
  Permalink  
Comments
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,
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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;
}
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 210
1 Richard MacCutchan 100
2 kbrandwijk 90
3 ChauhanAjay 80
4 ProgramFOX 80
0 Sergey Alexandrovich Kryukov 9,050
1 OriginalGriff 8,151
2 CPallini 2,613
3 Richard MacCutchan 2,221
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web03 | 2.8.140827.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