[英]Mimekit send email Apple does not render html
When I send emails through C#
using library Mimekit everything is fine, but when I want to open them from the Apple application, the screen is blank (it does not interpret the html
or CSS
)当我使用库Mimekit通过
C#
发送电子邮件时,一切都很好,但是当我想从 Apple 应用程序打开它们时,屏幕是空白的(它不解释html
或CSS
)
var email = new MimeMessage();
email.Sender = MailboxAddress.Parse(_mailSettings.Value.Mail);
email.To.Add(MailboxAddress.Parse(mail.Email));
email.Subject = mail.Subject;
var builder = new BodyBuilder();
builder.HtmlBody = mail.Body;
email.Body = builder.ToMessageBody();
using var smtp = new SmtpClient();
smtp.Connect(_mailSettings.Value.Host, _mailSettings.Value.Port, SecureSocketOptions.StartTls);
smtp.Authenticate(_mailSettings.Value.Mail, _mailSettings.Value.Password);
await smtp.SendAsync(email);
smtp.Disconnect(true);
Instead of email.Sender = MailboxAddress.Parse(_mailSettings.Value.Mail);
而不是
email.Sender = MailboxAddress.Parse(_mailSettings.Value.Mail);
, you should be using email.From.Add(MailboxAddress.Parse(_mailSettings.Value.Mail));
,你应该使用
email.From.Add(MailboxAddress.Parse(_mailSettings.Value.Mail));
The Sender
header works like the From
header, but is only meant to be used if it is different from the From
header or if the From
header contains multiple addresses. Sender
header 的工作方式与From
header 类似,但仅在与From
header 不同或From
header 包含多个地址时才使用。
That may or may not fix the Apple mail rendering issue (the mail rendering issue is probably an HTML code issue, not an email issue).这可能会或可能不会解决 Apple 邮件呈现问题(邮件呈现问题可能是 HTML 代码问题,而不是 email 问题)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.