7

I'm using System.Net.Mail.SmtpClient.

I build my MailMessage. IsBodyHtml is set to true. The Body is some html with some links.

Occasionally, some strange behavior occurs - an extra period will get added to one of the links. for example, the link will be set to this in the MailMessage Body:

<a href="http://www.myapp.com/company/contact">Contact Us</a>

but the email received shows up with an extra period:

<a href="http://www.myapp..com/company/contact">Contact Us</a>

The really strange behavior is that sometime the extra period will be added to a different link and sometimes it won't be added at all!

Is this a bug with System.Net.Mail.SmtpClient? Because the Body in the MailMessage does not have the extra period right as it's sent:

_smtp.Send(message); //message.Body has no extra period during sending

Note, I am using DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory which is writing the email to a file.

Update: I'm don't think this actually fixed it, but by setting message.BodyEncoding = System.Text.Encoding.UTF8;, I can't seem to reproduce the bug. Any ideas why that may have fixed it?

13
  • Never had that happen to me before. Are you setting IsBodyHtml?
    – itsme86
    Nov 10, 2016 at 17:41
  • @itsme86 IsBodyHtml is set to true. Yeah it's really strange. Nov 10, 2016 at 17:45
  • Are you hard coding the href in anchor tag or is it generated by some other method. This is really weird if it's happening after hard coding the href. Nov 10, 2016 at 17:50
  • Are you able to reproduce the problem every time? Can you narrow down what exactly is necessary to cause this to happen?
    – mason
    Nov 10, 2016 at 17:53
  • 1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy