I need to send an email to a recipient with international characters in the email address. An example email would be:
GaÙl@asterixthe.com
I've done quite a bit of searching but the information I'm finding is for the body and not the recipient. Do I need to mime encode this in some way and if so, how?
The code I've got is below:
MailMessage mailMessage =
new MailMessage(email.SenderEmailAddress, email.RecipientEmailAddress, "Why hello there!", emailMessage)
{
IsBodyHtml = true,
BodyEncoding = new System.Text.UTF8Encoding()
};
SmtpClient smtpClient = new SmtpClient("localhost")
{
Port = 25,
};
smtpClient.Send(mailMessage);
Thanks,
Simon
Edit: Here's the exception
System.FormatException: The specified string is not in the form required for an
e-mail address.
at System.Net.Mime.MailBnfHelper.ReadMailAddress(String data, Int32& offset,
String& displayName)
at System.Net.Mime.MailBnfHelper.ReadMailAddress(String data, Int32& offset)
at System.Net.Mail.MailAddressCollection.ParseValue(String addresses)
at System.Net.Mail.MailAddressCollection.Add(String addresses)
at System.Net.Mail.Message..ctor(String from, String to)
at System.Net.Mail.MailMessage..ctor(String from, String to)
at System.Net.Mail.MailMessage..ctor(String from, String to, String subject,
String body)