How do I send an email with accented letters? Example is pepé@lefrenchplace.com
, which should be supported now with RFC 6532
If I send an email to pepé@lefrenchplace.com
from gmail's web interface, it is delivered no problem.
I'm using .NET 4.6.1
, C#
, and SendGrid
.
First attempt with SMTP:
var smtp = new SmtpClient(Server)
{
Credentials = new NetworkCredential(Username, ApiKey),
DeliveryFormat = SmtpDeliveryFormat.International
};
var message = new MailMessage(From, To)
{
Subject = Subjet,
Body = BodyPlainText
};
smtp.Send(message);
This throws an SmtpException
with the message The client or server is only configured for E-mail addresses with ASCII local-parts: pepé@lefrenchplace.com.
Second attempt API V3 with SendGrid C# library
var apiKey = Environment.GetEnvironmentVariable("NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY");
var client = new SendGridClient(apiKey);
var from = new EmailAddress("test@example.com", "Example User");
var subject = "Sending with SendGrid is Fun";
var to = new EmailAddress("pepé@lefrenchplace.com", "Example User");
var plainTextContent = "and easy to do anywhere, even with C#";
var htmlContent = "<strong>and easy to do anywhere, even with C#</strong>";
var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
var response = await client.SendEmailAsync(msg);
I get an Accepted
status code returned. On the SendGrid dashboard it shows as Dropped with Invalid as the reason.