0

I am using SmtpClient to send a simple MailMessage

MailMessage mailMessage = new MailMessage("xyz@mydomain.com", "target@mydomain.com");
mailMessage.Subject = string.Format("{0} Notification Item", communication);

In my body I have.

mailMessage.BodyEncoding = Encoding.UTF8;
mailMessage.IsBodyHtml = true;

string Message = string.Format("You have received a new {0} notification from: {1} on Site: {2} please click <a href=\"{3}\">HERE</a> To view this notification item. <br/>Url: {3}<br/>",
new object[] { communicationType.ToString(), Employee.Name, Employee.DefaultSite.Name, thebuilder.Uri.OriginalString });

Now this all works however when I send the email to my outlook account through exchange. It changes the Url to read %3F instead of a '?' From what I've read this is because Microsoft Exchange does URL Encode.

Any idea how I can fix this or anyone have experience in perhaps why this would not work.

TheMonkeyMan
  • 8,622
  • 8
  • 27
  • 42
  • Look here http://stackoverflow.com/questions/5307923/asp-net-mailmessage-bodyencoding-and-mailmessage-subjectencoding-defaults – opewix Sep 07 '12 at 09:11
  • 1
    Your worked app web or win app?,for Web app from MS Helper yet.`ASP.NET Web Pages reference - System.Web.Helpers.dll in WebMail - good worked and all html tage & encoding fully supported.` – Elyor Sep 07 '12 at 10:59

1 Answers1

0

The solution is to not use the URL Builder as adding a '?' inside its (QueryString) attribute it casts this to a %3F.

TheMonkeyMan
  • 8,622
  • 8
  • 27
  • 42