-1

When the mail is received, in "from", I need to show the name of the person behalf of whom the mail is sent. I think what I need is the c# version of this answer

Thanks in advance

Arun Kumar A.J
  • 121
  • 1
  • 7

1 Answers1

2

Try a look to MailMessage class. You have an example on that page.

MailAddress from = new MailAddress("ben@contoso.com", "Ben Miller");
MailAddress to = new MailAddress("jane@contoso.com", "Jane Clayton");
MailMessage message = new MailMessage(from, to);

message.Subject = "Using the SmtpClient class.";
message.Body = @"Using this feature, you can send an e-mail message from an application very easily.";
SmtpClient client = new SmtpClient();
client.Send(message);

Be aware that SmtpClient, without params, takes the configuration from app.config / web.config. You can see the mailSettings section for further configuration information

mnieto
  • 3,744
  • 4
  • 21
  • 37
  • This assumes OP is using `SmtpClient` and not a SendGrid SDK. – DavidG Sep 10 '18 at 10:56
  • And if it is just `SmtpClient`, this is a duplicate... – DavidG Sep 10 '18 at 10:57
  • I would link to https://learn.microsoft.com/en-us/dotnet/api/system.net.mail.mailaddress?redirectedfrom=MSDN&view=netframework-4.7.2 instead. It is more detailed regarding this topic. – Cleptus Sep 10 '18 at 10:57