Html IFrame tag is not being interpret in email body

删除回忆录丶 提交于 2019-12-12 17:17:38

问题


I need to send a html file(which contains a iframe) inside a email body.The html file is working fine in a browser and playing a video.But when i send it inside email body,iframe tag is not getting interpreted so does not show in the body. This is html file.

<b>Aman</b>
<iframe height="390" frameborder="0" width="640"
src="http://www.youtube.com/embed/Sf5T5KjMpJU?wmode=transparent"
title="YouTube video player"></iframe>

Email body only displaying a "Aman" in bold.This is C# code.

        StreamReader reader = File.OpenText("C:\\Users\\Girish\\Desktop\\amrit\\Jeff_Project\\indeex.html");
        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";
        message.IsBodyHtml = true;
        message.Body = reader.ReadToEnd();
        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");

Why iframe is not being interpret?Am i missing anything?

Please help and provide solutions.

Thanks in advance.


回答1:


emails doesn't support objects tags inside them. read this

I even tried to send myself a youtube video from youtube, and even them not embedding the video in side the email body.

Instead of trying to embed the video as a link (like youtube does)




回答2:


most email clients only support very basic html. to be safest, we have to generate our newsletter content using table layouts and just simple a, span, and img tags for content.

if you try to use divs for layouts, outlook clients will barf when trying to render them. this is because outlook uses microsoft word to render html documents. as a general rule, we always test layouts in microsoft outlook because that client tends to be the lowest common denominator. if it looks good in outlook, it'll generally look good everywhere else.



来源:https://stackoverflow.com/questions/12652770/html-iframe-tag-is-not-being-interpret-in-email-body

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!