I've written an automated e-mailer for my company's invoices. Things are all fine and dandy till I ran across a couple emails that weren't getting delivered.
Upon further inspection our IT Guru found that the messages sent by the emailer have incorrect MessageID headers.
Message-ID: <98bcd4e6-be30-4b22-8026-6047c8231b1f>
Where they should look something like this:
Message-ID: <F09A215A213060419E28A88E85FDC8FD0CCEB91C23@EXCHANGE-SERVER.MYDOMAIN.mycompany.com>
I've looked around the internet for 'invalid message-id' related to .NET's SqlClient with no success. This is prettymuch the last lynch-pin in this whole system, hopefully there's an answer out there.
Code:
MailMessage message = new MailMessage();
foreach(string recipient in msgRecipients)
{
message.To.Add(new MailAddress(recipient));
}
message.From = new MailAddress(InvoiceEmailerConfig.Section.EmailCourier.FromEmail);
message.ReplyTo = new MailAddress(InvoiceEmailerConfig.Section.EmailCourier.ReplyToEmail);
message.Subject = messageHeading;
message.Body = msgBody;
SmtpClient mailer = new SmtpClient(SmtpServer, SmtpServerPort);
mailer.DeliveryMethod = SmtpDeliveryMethod.Network;
mailer.Credentials = new NetworkCredential(SmtpLogin, SmtpPassword);
mailer.Send(message);