2013-02-01 58 views
-2

我幾乎花了一天時間就可以了,但不能修復它,發送HTML內容

我感到電子郵件正文中發送HTML(asp.net 3.5),但問題是,它既不需要內格身體也沒有任何內嵌樣式,

message.Body = "<html>"+ 
           "<body>"+ 
           "<div style=\"background-color:yellow;\">" + 
            "<h3>"+ 
            " Congrats" + " " + userName + " " + " You have been shortlisted for interview. Please appear on " + " " + date +", "+time+" "+ "for interview"+ 
            "</h3>"+ 
           "</div>"+ 
           "</body>"+ 
           "</html>"; 

大膽的作品標籤很好,/,但它沒有考慮身體的任何風格,甚至div標籤,爲什麼呢?

+0

您能否列出完整的發送代碼?你在檢查什麼電子郵件客戶端?連接大量字符串時,請考慮[StringBuilder](http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx)。或者在這種情況下,也許http://stackoverflow.com/questions/886728/generating-html-email-body-in-c-sharp – MikeSmithDev

回答

1

在MailMessage上將IsHTML標誌設置爲true。

+0

我已經將其設置爲true message.IsBodyHtml = true; 但是沒有效果:( –

+0

像@MikeSmithDev所建議的那樣發佈你的方法的完整代碼。我似乎記得,這並不像應該那樣直截了當,而且有幾個箍環你必須跳過。 – markp3rry