SMTPClient for Gmail中的HTML格式

时间:2011-08-17 04:57:13

标签: c# smtpclient

我使用SMTPClient将带有html格式的邮件发送到Gmail但收到的邮件以纯文本显示..

这是我的代码:

SmtpClient SmtpClient = new SmtpClient();
            using (MailMessage MailMessage = new MailMessage())
            {
                MailAddress FromMailAddress = new MailAddress(_Cred_userName);
                MailAddress ToMailAddress = new MailAddress(_toAddress);
                SmtpClient.Credentials = new NetworkCredential(_Cred_userName, _Cred_passWord);
                SmtpClient.Port = _Cred_port;
                SmtpClient.Host = _Cred_host;
                MailMessage.From = FromMailAddress;
                MailMessage.To.Add(ToMailAddress);
                MailMessage.Subject = _subject;
                MailMessage.IsBodyHtml = true;
                MailMessage.Body = _body;                    
                foreach (var items in _attachmentCol)
                {
                    Attachment att = new Attachment(items);
                    MailMessage.Attachments.Add(att);
                }

                SmtpClient.EnableSsl = true;
                SmtpClient.Send(MailMessage);

            }

_body 包含:

 <html>
<head>
    <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" /><title>
    </title>
    <style type="text/css">
        .cs7CED571B{text-align:left;text-indent:0pt;padding:0pt 0pt 0pt 0pt;margin:0pt 0pt 0pt 0pt}
        .cs5B0A87D4{color:#000000;background-color:transparent;font-family:Times New Roman; font-size:12pt; font-weight:normal; font-style:normal; text-decoration: line-through;}
        .csB86C8CFE{color:#000000;background-color:transparent;font-family:Times New Roman; font-size:12pt; font-weight:bold; font-style:normal; }
        .csA62DFD6A{color:#000000;background-color:transparent;font-family:Times New Roman; font-size:12pt; font-weight:normal; font-style:italic; }
        .cs36E2AA4C{color:#000000;background-color:transparent;font-family:Times New Roman; font-size:8pt; font-weight:normal; font-style:normal; }
    </style>
</head>
<body>
    <span><p class="cs7CED571B"><span class="cs5B0A87D4">T</span><span class="csB86C8CFE">e</span><span class="csA62DFD6A">s</span><sup><span class="cs36E2AA4C">t</span></sup></p></span></body>

Gmail 仅收到

  

测试

gmail是否有自己的电子邮件html格式? :) 还有其他方法在gmail中显示html格式吗?

DevExpress RichTextEditor.htmlText 获取 _body html数据

事先感谢您的帮助.. :)

0 个答案:

没有答案