views:

580

answers:

1

I am using the following code to send an email in .Net2.0.

MailMessage message = new MailMessage();
message.From = new MailAddress("[email protected]", "[email protected] on behalf of someone else");
message.To.Add("[email protected]");
message.IsBodyHtml = true;
message.Body = "some actual html here, not just a string literal"
message.Subject = "Alert email from www.mydomain.com";

SmtpClient client = new SmtpClient("MySmtpClient.com", 25);
client.Send(message);

The problem I am experiencing is that when I check my email inbox, the from field of the email shows "[email protected]" and not "[email protected] on behalf of someone else", i.e. it's showing just the from email address instead of the DisplayName.

I've tried setting message.ReplyTo the same as I've set message.From but this seems to make no difference.

Am I missing something here?

A: 

Hi,

Try adding a Sender header.

For example

message.Headers.Add( "Sender", "[email protected]" )

Cheers!

Dave

dave wanta
Doesn't seem to work for me.
mdresser