Answered by:
How to set the MAIL FROM envelope when using SmtpDeliveryMethod.PickupDirectoryFromIis

Question
-
Hi,
When you send an email using System.Net.Mail you can set the SMTP MAIL FROM envelope by using the MailMessage.Sender Property.
If you set the smtp network deliveryMethod property to be "Network", the MAIL FROM envelope is set using the Sender value.
If you set the smtp network deliveryMethod property to be "PickupDirectoryFromIis", the MAIL FROM envelope uses the MailMessage.From property instead of the Sender one.
Any suggestion how to keep the value I need for the SMTP MAIL FROM envelope?
Thanks
Monday, January 19, 2009 11:37 PM
Answers
-
The bug report has just been updated:
"Fix will appear in a future release of the .Net framework."
There's no indication which release - I would hope it makes it into v4.- Marked as answer by Nipiap Tuesday, September 22, 2009 2:01 PM
Tuesday, September 22, 2009 11:09 AM
All replies
-
This doesn't sound right. I'll do some research and come back to you. Can you post a code snippet? It will make it faster for me
Thanks
MariyaFriday, February 6, 2009 2:05 AMModerator -
Hi Mariya,
Thanks for the reply. Sorry for the delay in my answer, I've somehow missed the notification.
Here is the code snippet I use.
You will notice the different MailMessage.From and MailMessage.Sender
using (MailMessage mailMsg = new MailMessage()) { mailMsg.Subject = "Subject"; mailMsg.Body = "Content"; mailMsg.To.Add(new MailAddress("null@example.com")); mailMsg.ReplyTo = new MailAddress(string.Format("\"{0}\" <{1}>", "exampleReply", " exampleReply@test.local")); mailMsg.From = new MailAddress(string.Format("\"{0}\" <{1}>", " exampleFrom", " exampleFrom@test.local")); mailMsg.Sender = new MailAddress("bounce@example.com"); SmtpClient client = new SmtpClient { Host = "localhost", DeliveryMethod = SmtpDeliveryMethod.Network, //DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis, }; client.Send(mailMsg); }
if I use the first delivery method (SmtpDeliveryMethod.Network), and I analyze the packets using Wireshark, here is what I have
23049 109.881909 192.168.XX.XXX 66.XXX.XX.XXX SMTP C: MAIL FROM:<bounce@example.com> SIZE=663
If I use SmtpDeliveryMethod.PickupDirectoryFromIis as my delivery method, here is what I see
32163 153.352097 192.168.XX.XXX 66.XXX.XX.XXX SMTP C: MAIL FROM:<exampleFrom@test.local> SIZE=601
Obviously the first result is the one I would like to keep.
Thanks
Tuesday, February 10, 2009 2:53 PM -
I've just run into the same problem; switching the delivery method to "network" fixed it.
I've reported this as a bug: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=483878Thursday, August 20, 2009 4:04 PM -
The bug report has just been updated:
"Fix will appear in a future release of the .Net framework."
There's no indication which release - I would hope it makes it into v4.- Marked as answer by Nipiap Tuesday, September 22, 2009 2:01 PM
Tuesday, September 22, 2009 11:09 AM -
I know this thread has been dormant for quite awhile, but is this confirmed to be fixed in the latest .net 4 build (RTM)?Friday, May 14, 2010 8:38 PM
-
I've just tested on .NET 4.0 RTM, and it looks like it's fixed.Tuesday, August 3, 2010 5:49 PM