相关疑难解决方法(0)

Django:如何发送带有嵌入图像的HTML电子邮件

如何发送包含嵌入图像的HTML电子邮件?HTML应该如何链接到图像?图像应添加为MultiPart电子邮件附件?

任何例子都非常感激.

html email django image

18
推荐指数
3
解决办法
2万
查看次数

创建一个MIME电子邮件模板,其中包含要使用python/django发送的图像

在我的Web应用程序中,我偶尔使用可重用的邮件程序应用程序发送电子邮件,如下所示:

user - self.user
subject = ("My subject")
from = "me@mydomain.com"
message = render_to_string("welcomeEmail/welcome.eml", { 
                "user" : user,
                })
send_mail(subject, message, from, [email], priority="high" )
Run Code Online (Sandbox Code Playgroud)

我想发送一封包含嵌入图像的电子邮件,所以我尝试在邮件客户端发送邮件,查看源代码,并将其放入我的模板(welcome.eml),但我一直无法将其渲染到正确地在邮件客户端发送时.

有没有人知道我有一个简单的方法来创建具有内联图像的mime编码邮件模板,当我发送它们时它们会正确呈现?

python email django mime

13
推荐指数
1
解决办法
2万
查看次数

使用C#发送电子邮件以在iOS中显示

我正在尝试从包含自定义样式和附件的C#SharePoint应用程序发送电子邮件.它使用模板结构,我已成功配置电子邮件以使用内联图像的新样式和附件,它可以很好地显示Outlook客户端.但是,当我尝试在iOS设备上查看电子邮件时,我会看到两次图像; 一旦内联,再次在电子邮件的末尾.

我能找到最接近解决方案的是为Django编写的,我没有太多成功将该解决方案移植到C#.我在这里找到答案:在iPhone,iPad上显示内嵌图像

我以这种方式配置附件:

System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(new MemoryStream(imageBytes.Key), MediaTypeNames.Image.Jpeg);
attachment.Name = imageBytes.Value;
attachment.ContentDisposition.Inline = true;
attachment.ContentId = imageBytes.Value;

attachments.Add(attachment);
Run Code Online (Sandbox Code Playgroud)

如何才能仅显示一次这些图像?我需要能够以只显示内联的方式显示它们.我不确定这是否意味着我应该使用替代视图,如果是,那么如何使用它们.

编辑:

以下是我用于生成电子邮件的其余代码:

public override System.Net.Mail.MailMessage GenerateMessage()
{
var keys = new Dictionary<string, string>();
var fileBytes = new Dictionary<byte[], string>();
var attachments = new List<System.Net.Mail.Attachment>();

var message = new MailMessage();

//get the attachment images as html in a dictionary object, byte[] and string   
fileBytes = GetEmailAttachments();

foreach (var imageBytes in fileBytes)
{
    System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(new MemoryStream(imageBytes.Key), …
Run Code Online (Sandbox Code Playgroud)

c# email html-email email-attachments ios

5
推荐指数
1
解决办法
2032
查看次数

标签 统计

email ×3

django ×2

c# ×1

email-attachments ×1

html ×1

html-email ×1

image ×1

ios ×1

mime ×1

python ×1