In this post I am want to tell how send behalf mail in C#.NET. Behalf of mail is means, it is like normal mail send only. But we will add Sender option in that mail header. So, I second side when they’re view that mail in from mail ID option they can see like this [sender mail ID] on behalf of [from mail ID].
We can send behalf of mail in C#.NET easily, same like VB.NET too. Please check with image how it will be in receiver side.. if you see this mail you can understand what is behalf of mail?..
![behalf-of-mail-in-dotnet Send Behalf of mail in C#.net](https://shareourideas.com/wp-content/uploads/2010/08/behalf-of-mail-in-dotnet.png?w=300)
Code:-
using System.Net.Mail; // import System.Net.Mail
void SendUsingNetMail() { SmtpClient smtp = new SmtpClient(); MailMessage msg = new MailMessage(my-name@domain.com, "user@userdomain.com"); msg.Sender = new MailAddress("my-mail-id@domain.com"); msg.Subject = "This is for Demo"; msg.Body = "This is just for demo about behalf of mail option in C#"; smtp.Send(msg); }
I hope it will helpful for you.
Note:- I tried with outlook it is showing correct, but it is not showing in gmail.com. I hope it will show only in OUTLOOK and Desktop mail softwares
Enjoy while coding..!
Thanks,
Naga Harish Movva.
Thanks, it worked.