2012-09-29 29 views
3

我需要發送一個html文件(其中包含一個iframe)在電子郵件正文內。html文件在瀏覽器中正常工作並播放視頻。但是當我發送它時在電子郵件正文內部,iframe標籤不會被解釋,因此不會顯示在正文中。 這是html文件。Html IFrame標籤沒有被解釋在電子郵件正文中

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

電子郵件正文僅以粗體顯示「Aman」。這是C#代碼。

 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"); 

爲什麼iframe沒有被解釋?我錯過了什麼嗎?

請幫助並提供解決方案。

在此先感謝。

+0

只有一些電子郵件客戶端支持iframes https://www.campaignmonitor.com/blog/post/3219/do-iframes-work-in-email/ 所以我會尋找不同的方法,如發送縮略圖帶有播放按鈕的視頻,並將圖像鏈接到將播放視頻的網站 –

回答

3

電子郵件不支持其中的對象標籤。 read this

我甚至試圖給自己發送youtube的YouTube視頻,甚至他們沒有將視頻嵌入電子郵件正文。

,而不是試圖嵌入視頻的鏈接(如YouTube一樣)

enter image description here

1

大多數電子郵件客戶端僅支持很基本的HTML。爲了保證安全,我們必須使用表格佈局和簡單的a,span和img標籤來生成我們的新聞稿內容。

如果您嘗試使用div進行佈局,則Outlook客戶端在嘗試渲染它們時會出現barf。這是因爲outlook使用微軟的word來呈現html文檔。作爲一般規則,我們總是在Microsoft Outlook中測試佈局,因爲該客戶端往往是最低的共同標準。如果外觀看起來不錯,那麼在其他地方通常會看起來不錯。

相關問題