gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 19:22:30 25 4
gpt4 key购买 nike

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

发送邮件的代码

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

我必须将什么写成 src

如有任何帮助,我们将不胜感激。

最佳答案

http://blog.devexperience.net/en/12/Send_an_Email_in_CSharp_with_Inline_attachments.aspx 也有很好的 sample

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

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

关于c# - 如何在邮件内容中显示图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11177587/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com