【问题标题】:How to send a IFrame in email body?如何在电子邮件正文中发送 IFrame?
【发布时间】:2012-09-20 22:21:54
【问题描述】:

如何在电子邮件正文中发送 iframe。这就是我发送邮件的方式。

        string getemail = textbox_email.Text;
        System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
        message.To.Add(getemail);
        message.Subject = "Hello";
        message.From = new System.Net.Mail.MailAddress("sendingemail");
        message.Body = "This is message body";
        System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
        smtp.Credentials = new System.Net.NetworkCredential("sendingemail", "password");
        smtp.EnableSsl = true;
        smtp.Send(message);
        Response.Write("Sent");

这是 html 中的 iframe。实际上 iframe 将包含 youtube 视频链接。

<iframe id="iframe" runat="server" src="http://www.w3schools.com"  scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe> 

如何在电子邮件正文中发送? 提前致谢。

【问题讨论】:

  • mailmsg.IsBodyHtml=true;
  • 谢谢,但是如何在正文中组合/附加 iframe?
  • 我认为 gmail 或任何其他注明的 smtps 会阻止您的 iframe。我检查了您的代码并且 gamil 正在阻止它。您可能需要寻找不同的选项。这是关于 IFRAMES 替代品的 so 帖子stackoverflow.com/questions/6719053/…

标签: c# asp.net email iframe


【解决方案1】:

您可以使用IsBodyHtml 属性或AlternativeViews 发送HTML。

如果您希望客户端会在您的 IFrame 中呈现内容,由于邮件客户端的安全限制(类似于阻止外部图像),这很可能不会发生。

【讨论】:

    【解决方案2】:

    虽然您的电子邮件收件人的客户端不太可能呈现 iframe,但根据您的预期目标,您可能需要查看 WebClient 类的 DownloadString 方法。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-16
    • 1970-01-01
    • 1970-01-01
    • 2021-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多