I've been using the System.Net namespace ever since we switched from .NET Framework 1.1 to the 3.5 framework, but there’s one thing that’s been puzzling me since. What's the difference between the Sender and the From properties in the MailMessage class?
Are they both the same, and if not is there a reason to use Sender together with From?
For example:
Using m As New System.Net.Mail.MailMessage()
m.Sender = New System.Net.Mail.MailAddress("[email protected]", "Name here")
m.From = New System.Net.Mail.MailAddress("[email protected]", "Name here")
m.Subject = "Test"
m.Body = "Test"
Dim client As New System.Net.Mail.SmtpClient("mymailserver.com")
client.Send(m)
End Using
message.Sender != null ? message.Sender : message.From. The result is SmtpClient does not allow you to send distinct values for Sender and From - Sam