我有一个原始电子邮件(MIME 文本),我用 OpenPop.Net 解析然后转换为 System.Net.Mail.MailMessage
Dim message As MailMessage
Dim openPopMsg As New OpenPop.Mime.Message(System.Text.Encoding.ASCII.GetBytes(mimeText))
message = openPopMsg.ToMailMessage()
Dim Client As SmtpClient
Client = New SmtpClient(account.Server, account.Port)
Client.Credentials = New System.Net.NetworkCredential(account.User, account.Password)
Client.EnableSsl = account.UseSSL
Client.DeliveryMethod = SmtpDeliveryMethod.Network
Client.Send(message)
Client.Dispose()
电子邮件已发送,附件发送正常等。唯一的问题是电子邮件的内容应该是 text/html,但我收到的 HTML 是 text/plain。
message.IsBodyHtml
设置为真
如何更改特定部分的内容类型或更好地进行正确转换?
原始的 mime 文本如下所示(这只是多部分电子邮件的一部分):
----boundary_27_d254c44c-5b54-4df3-ac69-ef73c8b0158b
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; charset=3D=
utf-8"><html><header><style>p{margin-top: 0;margin-bottom: 0;line=
-height: 100%}ul,li{padding: 0px;margin: 0px;margin-top: 0;margin=
-bottom: 0}</style></header><body><p style=3D"text-align:left;"><=
span style=3D"font-bold:false;color:rgb(0,0,0);"><font face=3D"Ar=
ial" style=3D"font-size:12pt;" >Mira este es el subjetct: This is=
an email test.</font></span></p><BR><BR><BR></body></html>
发送的电子邮件具有以下 MIME 文本:
----boundary_3_d722cdce-a270-41b5-aa4e-33aa9131512a
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; charset=3D=
utf-8"><html><header><style>p{margin-top: 0;margin-bottom: 0;line=
-height: 100%}ul,li{padding: 0px;margin: 0px;margin-top: 0;margin=
-bottom: 0}</style></header><body><p style=3D"text-align:left;"><=
span style=3D"font-bold:false;color:rgb(0,0,0);"><font face=3D"Ar=
ial" style=3D"font-size:12pt;" >Mira este es el subjetct: This is=
an email test.</font></span></p><BR><BR><BR></body></html>