rtf图片未显示在Gmail中

时间:2018-07-20 12:39:01

标签: c# outlook gmail

我正在使用MailItem.RtfBody通过Outlook发送邮件。 图片和表格会出现在Outlook发送的邮件中, 但Gmail不显示图像和表格。我正在用C#编写该项目

Gmail收件箱文件夹:

enter image description here

Outlook已发送邮件文件夹:

enter image description here

代码:

Outlook.Application OutApp = new Outlook.Application();
MailItem OutEmail;
OutEmail = OutApp.CreateItem(OlItemType.olMailItem);
OutEmail.BodyFormat = OlBodyFormat.olFormatRichText;
OutEmail.RTFBody = System.Text.Encoding.ASCII.GetBytes(email.Sablon.Metin);


Outlook.Accounts accounts = OutApp.Session.Accounts;
foreach (Outlook.Account account in accounts)
{
    if (account.SmtpAddress == Email.pKimden)
    {
        OutEmail.SendUsingAccount = account;
    }
}

if (!String.IsNullOrEmpty(Email.pKimden))
{
    OutEmail.SentOnBehalfOfName = Email.pKimden;

}

if (!String.IsNullOrEmpty(Email.pKime))
{
    OutEmail.To = Email.pKime;
}

if (obj.Sablon.ManuelGonderim == true || String.IsNullOrEmpty(Email.pHata) == false)
{
    OutEmail.Display();
    Email.pGonderildi = false;
}
else
{
    OutEmail.Send();
    Email.pGonderildi = true;
}

邮件源代码(Gmail)
img src =“ rtfimage://”不是真实的源,创建时未添加表格边框。

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Bodoni MT Black" size="3"><span style="font-size:12pt;">
<div style="text-align:center;"><font color="blue"> <img width="1005" height="175" src="rtfimage://"></font></div>
<div style="text-align:center;"><font face="Microsoft Sans Serif" size="2" color="blue"><span style="font-size:8.5pt;">&nbsp;</span></font></div>
<div style="text-align:center;"><font color="blue"> elif<font face="Microsoft Sans Serif"> </font></font></div>
<table width="755" style="width:453.1pt;margin-left:5.65pt;">
<col width="125" style="width:75.5pt;">
<col width="125" style="width:75.5pt;">
<col width="125" style="width:75.5pt;">
<col width="125" style="width:75.5pt;">
<col width="125" style="width:75.55pt;">
<col width="125" style="width:75.55pt;">
<tr>
<td><font face="Microsoft Sans Serif"></font></td>
<td><font color="blue"> elif<font face="Microsoft Sans Serif"> </font></font></td>
<td><font face="Microsoft Sans Serif"></font></td>
<td><font face="Microsoft Sans Serif"></font></td>
<td><font face="Microsoft Sans Serif"></font></td>
<td><font face="Microsoft Sans Serif"></font></td>
</tr>
<tr>
<td><font face="Microsoft Sans Serif"></font></td>
<td><font face="Microsoft Sans Serif"></font></td>
<td><font color="blue"> elif<font face="Microsoft Sans Serif"> </font></font></td>
<td><font face="Microsoft Sans Serif"></font></td>
<td><font color="blue"> elif<font face="Microsoft Sans Serif"> </font></font></td>
<td><font face="Microsoft Sans Serif"></font></td>
</tr>
<tr>
<td><font face="Microsoft Sans Serif"></font></td>
<td><font face="Microsoft Sans Serif"></font></td>
<td><font face="Microsoft Sans Serif"></font></td>
<td><font face="Microsoft Sans Serif"></font></td>
<td><font face="Microsoft Sans Serif"></font></td>
<td><font face="Microsoft Sans Serif"></font></td>
</tr>
<tr>
<td><font face="Microsoft Sans Serif"></font></td>
<td><font face="Microsoft Sans Serif"></font></td>
<td><font color="blue"> elif<font face="Microsoft Sans Serif"> </font></font></td>
<td><font face="Microsoft Sans Serif"></font></td>
<td><font face="Microsoft Sans Serif"></font></td>
<td><font face="Microsoft Sans Serif"></font></td>
</tr>
<tr>
<td><font face="Microsoft Sans Serif"></font></td>
<td><font face="Microsoft Sans Serif"></font></td>
<td><font face="Microsoft Sans Serif"></font></td>
<td><font face="Microsoft Sans Serif"></font></td>
<td><font color="blue"> elif<font face="Microsoft Sans Serif"> </font></font></td>
<td><font face="Microsoft Sans Serif"></font></td>
</tr>
</table>
<div><font face="Microsoft Sans Serif">&nbsp;</font></div>
</span></font>
</body>
</html>
游击邮件显示来源:enter link description here enter code here 收件箱中的游击邮件enter image description here

1 个答案:

答案 0 :(得分:0)

除Outlook以外的电子邮件客户端实际上并不喜欢RTF格式。尝试设置HTMLBody属性而不是RtfBody。通过添加附件并将内容ID设置为HTML正文中cid标签的匹配img属性,可以将图片添加到HTML。