如何发送带有重音字母的电子邮件?例如, RFC 6532pep\xc3\xa9@lefrenchplace.com现在应该支持它
pep\xc3\xa9@lefrenchplace.com如果我从 gmail 的网络界面发送电子邮件,则发送没有问题。
我正在使用.NET 4.6.1、C#和SendGrid。
第一次尝试使用 SMTP:
\nvar smtp = new SmtpClient(Server)\n{\n Credentials = new NetworkCredential(Username, ApiKey),\n DeliveryFormat = SmtpDeliveryFormat.International\n};\n\nvar message = new MailMessage(From, To)\n{\n Subject = Subjet,\n Body = BodyPlainText\n};\n\nsmtp.Send(message);\nRun Code Online (Sandbox Code Playgroud)\n这会抛出一个SmtpException带有消息的The client or server is only configured for E-mail addresses with ASCII local-parts: pep\xc3\xa9@lefrenchplace.com.
var apiKey = Environment.GetEnvironmentVariable("NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY");\nvar client = new SendGridClient(apiKey);\nvar from = new EmailAddress("test@example.com", "Example User");\nvar subject = "Sending with SendGrid is Fun";\nvar to = new EmailAddress("pep\xc3\xa9@lefrenchplace.com", "Example User");\nvar plainTextContent = "and easy to do anywhere, even with C#";\nvar htmlContent = "<strong>and easy to do anywhere, even with C#</strong>";\nvar msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);\nvar response = await client.SendEmailAsync(msg);\nRun Code Online (Sandbox Code Playgroud)\n我收到Accepted返回的状态代码。在 SendGrid 仪表板上,其原因显示为已删除且无效。