我嘗試將HTML發送到gmail帳戶,從Gmail到SMTP服務器。爲什麼編碼標頭內容類型:text/html;在Outlook插件中使用MailItem時缺少GMAIL的SMTP服務器:SMTP.GMAIL.COM?
如果我編寫這樣的代碼併發送HTML,則沒有問題。
MailMessage mail = new MailMessage("[email protected]", to, subject, body);
mail.IsBodyHtml = true;
SmtpClient smtpClient = new SmtpClient(smtp);
smtpClient.EnableSsl = true;
smtpClient.Port = 587;
smtpClient.Credentials = new NetworkCredential(userName, password);
smtpClient.Send(mail);
在Gmail帳戶收到的電子郵件是用base64 隨着頭:
Subject: Test
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: base64
PGh0bWw==
(該基地64是無效的,這只是針對這個問題)
但是,如果我使用Outlook.MailItem發送我的電子郵件,那就是我所得到的......
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<https://fdsafasdfasd.com/images/logo.png> =09
Cedric Boivin
[email protected]
Vous a envoy=E9 un message s=E9curis=E9 vifdasfasdfes
我的文字看起來很清晰,而不是Gmail中的HTML。有我的代碼在Outlook插件
Microsoft.Office.Interop.Outlook.MailItem newMail = Globals.ThisAddIn.Application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
// newMail.Display(false);
newMail.Subject = subject;
newMail.To = email.ToLower().Trim();
newMail.Recipients.ResolveAll();
newMail.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
newMail.HTMLBody = htmlBody;
newMail.Send();
任何建議嗎?
幹得好,也許鏈接到你問的變體上的這個答案,將來會幫助別人。 –