.NET Framework Bookmark and Share   
 index > Network Class Library (System.Net) > How to set the MAIL FROM envelope when using SmtpDeliveryMethod.PickupDirectoryFromIis
 

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

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
  •  
Nipiap
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 byNipiap Tuesday, September 22, 2009 2:01 PM
  •  
richard_deeming
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
Mariya
Mariya Atanasova [NCL]
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(MailMessagemailMsg=newMailMessage())
{
mailMsg.Subject="Subject";
mailMsg.Body="Content";
mailMsg.To.Add(newMailAddress("null@example.com"));
mailMsg.ReplyTo=newMailAddress(string.Format("\"{0}\"<{1}>","exampleReply","exampleReply@test.local"));
mailMsg.From=newMailAddress(string.Format("\"{0}\"<{1}>","exampleFrom","exampleFrom@test.local"));
mailMsg.Sender=newMailAddress("bounce@example.com");
SmtpClientclient=newSmtpClient
{
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
Nipiap
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=483878
richard_deeming
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 byNipiap Tuesday, September 22, 2009 2:01 PM
  •  
richard_deeming

You can use google to search for other answers

Custom Search

More Threads

• how SocketEventAsyncArgs works
• About the Socket.SendPacketsAsync() method...
• Mikrotik Bandwdth teste application
• SMTPClient is not sending Authentication for server with DIGEST-MD5 CRAM-MD5
• Asynchronous System.Net.Sockets.UdpClient problem
• About Webclient
• WebClient.UploadFile and WebClient.UploadValues in the same call
• Is there a way to find out/measure the socket receiving backlog queue length?
• How can I convert from HttpWebRequest to use Sockets?
• System.Net.Mail SMTP Fails to Request Connection with Server