Hoping someone will be able to help out with this, I've been looking round and I can't seem to find an answer anywhere.
I'm creating a mail message using that will be delivered to a specified pickup directory, this code has been used numerous times in the past without issue. Now though, when I inspect the resulting file and more specifically a URL within the eml file, I can see that in the middle there is a double .
. From what I've been reading, I understand that this is part of the SMTP protocol to dot stuff if the first character of a line in the message begins with .
. This file is later going to be picked up by another service that will ultimately carry out the sending of the email.
I've been able to narrow it down to the exact line when I call client.Send()
. If I inspect the message body before the send, the URL is correctly formed. Inspecting the message body after I have called it, there is the ..
present in the URL.
My question, or questions I suppose, are as follows:
- Has anyone else come across an issue with dot stuffing when using
SmtpDeliveryMethod.SpecifiedPickupDirectory
? - Whose job is it to correctly handle this? The .NET SMTP or the secondary service that picks this message up at a later date and sends it on to the final destination?
- Any advice on how to resolve this?
I have previously tried the approach described here, but it fails with numerous exceptions.
I'm mainly looking for a way to save this eml file to a location on disk that can later be picked back up and sent, my knowledge on C# is still fairly limited so there may be something simple I am just over looking, so any advice or guidance would be hugely appreciated!
I have created a small sample piece of code to try and recreate the issue, this isn't the exact content I'm using, but it does show that after sending via the client.Send() method, there are 2 '..' at the start of the string.
using (var client = new SmtpClient())
{
client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
client.PickupDirectoryLocation = @"C:\temp";
var message = new MailMessage();
message.To.Add(new MailAddress("alice@a.com"));
message.From = new MailAddress("bob@b.com");
message.Subject = "Smtp Dot Stuffing Test";
message.Body = ".A.B.C..... .0.1.2.3.4.5.6.7.8.9";
client.Send(message);
}