Why can I get error 5.5.4 Invalid Address?

I tried to send an email using the following code:

MailMessage message = new MailMessage(); message.From = new MailAddress(fromMailAddress.Trim()); message.To.Add(new MailAddress(toMailAddress.Trim())); message.Subject = subject; message.Body = body; message.SubjectEncoding = System.Text.Encoding.UTF8; message.BodyEncoding = System.Text.Encoding.UTF8; SmtpClient client = new SmtpClient(); try { client.Send(message); } catch(Exception e) { throw e; } 

However, I got an exception:

Server response: 5.5.4 Invalid address

Everything is correct on behalf of email, email, server host name and port. The exact same code with the same input values ​​works on another machine in our office

+1
source share
2 answers

Found out the answer after some thorough debugging.

It turns out that my car name has the character "Γ₯" (invalid Swedish character). After that he worked.

+1
source

KB was released for System.Net.Mail, which affected address parsing and Unicode, so the reason it worked on one computer and not the other was most likely present in this KB..NET 4.0 also has some significant improvements in analysis of email addresses.

+1
source

All Articles