views:

143

answers:

2

My Email Sending Code

 MailMessage msg = new MailMessage("[email protected]", "[email protected]", "testing email", "to check from email label text");
    SmtpClient smpt = new SmtpClient();
    smpt.Send(msg);

When email open by [email protected] user, In the from email, its mentioned [email protected] where as I need to show like Abc Corporation [[email protected]]

How can I change from Email address label

Thanks

+1  A: 

Use the DisplayName

MailMessage m = new MailMessage();
m.From = new MailAddress("[email protected]", "My Mail");
Anuraj
+1  A: 

Create a MailAddress with the real name and email address, then supply that to the MailMessage.

From MSDN (From property for MailMessage).

  MailAddress from = new MailAddress("[email protected]", "Ben Miller");
  MailAddress to = new MailAddress("[email protected]", "Jane Clayton");
  MailMessage message = new MailMessage(from, to);
tvanfosson
Thanks for the solution, it will showing like Nextech Corporation [mailto:[email protected]] ([email protected]) but I need Nextech Corporation [mailto:[email protected]]
Muhammad Akhtar
([email protected]) this will not want to show.
Muhammad Akhtar
Now I have passed the real EmailAddress, Always when I post these kinds of thing I prefer to post dummy, just for understanding
Muhammad Akhtar