场景 我想用谷歌地图发送 iframe。我一直在尝试这样做,但我发现我的邮件根本不是以 HTML 格式发送的。
正文
<p><iframe src=\"https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d80106.40796404252!2d16.840744817766343!3d51.13935304292101!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x4d72b9e9e002427b!2sStudio+PLAN!5e0!3m2!1spl!2spl!4v1534413878645\" width=\"600\" height=\"450\" frameborder=\"0\" style=\"border:0\" allowfullscreen></iframe></p>
*收到邮件
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d80106.40796404252!2d16.840744817766343!3d51.13935304292101!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x4d72b9e9e002427b!2sStudio+PLAN!5e0!3m2!1spl!2spl!4v1534413878645" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>
代码
try
{
SmtpMail oMail = new SmtpMail(_eaSendMailLicence);
SmtpClient oSmtp = new SmtpClient();
oMail.To = new AddressCollection(email.Receiver);
oMail.From = new MailAddress(senderConfiguration.SenderName,senderConfiguration.Email);
oMail.Subject = subject;
oMail.HtmlBody = htmlBody;
//oMail.TextBody = textBody;
oMail.Charset = "utf-8";
SmtpServer oServer = new SmtpServer(senderConfiguration.SmtpHost, senderConfiguration.SmtpPort);
oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
oServer.User = senderConfiguration.Username;
oServer.Password = GetPlainPassword(senderConfiguration.Password);
oSmtp.SendMail(oServer, oMail);
}