2011-03-30 4 views

답변

32

D' 오, 이건 정말 간단합니다 ...하지만 나 같은, 인터넷 검색을하기 전에 대답을 SO에보고했다, 누군가를 위해 여기에 대답을 떠날거야 ... :)

신용에 this article.

사용 AlternateViews, 그래서 같은 :

//create the mail message 
var mail = new MailMessage(); 

//set the addresses 
mail.From = new MailAddress("[email protected]"); 
mail.To.Add("[email protected]"); 

//set the content 
mail.Subject = "This is an email"; 

//first we create the Plain Text part 
var plainView = AlternateView.CreateAlternateViewFromString("This is my plain text content, viewable by those clients that don't support html", null, "text/plain"); 
//then we create the Html part 
var htmlView = AlternateView.CreateAlternateViewFromString("<b>this is bold text, and viewable by those mail clients that support html</b>", null, "text/html"); 
mail.AlternateViews.Add(plainView); 
mail.AlternateViews.Add(htmlView); 

//send the message 
var smtp = new SmtpClient("127.0.0.1"); //specify the mail server address 
smtp.Send(mail); 
+6

당신이 MediaTypeNames.Text.Plain 또는 그 대신 "text/plain」와 「text의 MediaTypeNames.Text.Html를 사용할 수있는 약간 더 강력한 형식의 시스템을 원하는 경우/html " – Talon

+1

나는 googled하고 그것은 나를 보내 : / – Beta033

관련 문제