Mail URI with special chars - The hostname could not be parsed

Viewed 53

I'm trying to create a new Uri() from the following email:

user+26/6@gmail.com

Via:

var x = new Uri("mailto:user+25/6@gmail.com");

But I keep getting: "The hostname could not be parsed"

If I send a message to that kind of email it gets delivered. I've seen it throws the exception as soon as it sees the combination of "+" and "/" on the email.

Any ideas how to bypass it?

1 Answers

From the documentation here "/" is special character for Uri Class. You can try using "\/" instead

var x = new Uri("mailto:user+25\/6@gmail.com");

to avoid it but I didn't tested.

Related