0

场景 我想用谷歌地图发送 iframe。我一直在尝试这样做,但我发现我的邮件根本不是以 HTML 格式发送的。

正文

<p>&lt;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&gt;&lt;/iframe&gt;</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);
}
4

1 回答 1

1

解决方案

问题是我的解析器更改<&lt;etc。不用将符号 < > 等替换为它们的代码就足够了。正如mjwills 所注意到的,根本不建议使用 iframe:

不建议在 html 电子邮件中使用 iframe - mailchimp.com/help/limitations-of-html-email campaignmonitor.com/blog/email-marketing/2010/08/...</a> 您应该改用静态地图 -开发人员。 google.com/maps/documentation/maps-static/intro – mjwills 20 小时前

于 2018-08-17T09:29:46.547 回答