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

Mat*_*ski 1 c# email webmail

我想在内容中发送包含一些图像的电子邮件.我想我必须将此图像作为电子邮件的附件附加,但我的问题是如何在邮件内容中使用附加图像?

发送邮件的代码

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

我必须写src什么?

任何帮助,将不胜感激.

小智 6

也是http://blog.devexperience.net/en/12/Send_an_Email_in_CSharp_with_Inline_attachments.aspx的好样本

System.Net.Mail.Message类:

样品;

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);
Run Code Online (Sandbox Code Playgroud)

您可以在http://msdn.microsoft.com/en-us/library/system.net.mail.attachment.aspx找到更多详细信息.