简体   繁体   English

如何显示邮件内容中的图像?

[英]How can I display images in mail content?

I want send e-mail with some images in content. 我想发送包含一些图像内容的电子邮件。 I think I must attached this images as attachments to e-mail, but my proble is how can I use attached images in mail content? 我认为我必须将此图像作为电子邮件的附件附加,但是我的问题是如何在邮件内容中使用附加的图像?

CODE WHICH SEND MAIL 发送邮件的代码

WebMail.SmtpServer = "my.smtp.server";
WebMail.Send(
        clientEmail,
        subject,
        "<html><head></head><body><img src='???' /></body></html>",
        myEmail,
        null,
        new List<string> () { "path" },
        true
    );

What I must write as src ? 我必须写为src吗?

Any help would be appreciated. 任何帮助,将不胜感激。

Also good sample at http://blog.devexperience.net/en/12/Send_an_Email_in_CSharp_with_Inline_attachments.aspx http://blog.devexperience.net/en/12/Send_an_Email_in_CSharp_with_Inline_attachments.aspx中也不错的示例

System.Net.Mail.Message Class : System.Net.Mail.Message类:

Sample ; 样品;

var msg = new System.Net.Mail.Message();
msg.isHTML=true;
msg.Body ="<img src=\"cid:IMG1CONTENT\">";


Attachment mya = new Attachment("file-path-here");
mya.ContentId="IMG1CONTENT";
msg.Attachments.Add(mya);

You can find more details @ http://msdn.microsoft.com/en-us/library/system.net.mail.attachment.aspx 您可以在http://msdn.microsoft.com/zh-cn/library/system.net.mail.attachment.aspx中找到更多详细信息

To display the images in email content, one solution is to have an absolute URL. 要显示电子邮件内容中的图像,一种解决方案是使用绝对URL。 Upload the images to your server and use the abosoluter url as the src attribute value 将图像上传到您的服务器,并使用abosoluter url作为src属性值

<img src='http://www.yourdomain.com/youfolder/image.jpg' alt='your image desc'/>

But some email clients will disable external images. 但是某些电子邮件客户端将禁用外部图像。 So user may need to enable "show images" when propmpted so. 因此,在提示时,用户可能需要启用“显示图像”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM