Get gmail Name instead of EmailID using C# in ASP.Net

on Sep 14, 2016 11:06 PM

Pls refer the below site

I could send email using this website.

But the reciever sees the sender's email id instead of his/her name as mentioned in the sender's  gmail account.

PLs help me on how to  send email with sender's name mentioned in the  receiver's inbox

Download FREE API for Word, Excel and PDF in ASP.Net: Download
on Sep 14, 2016 11:40 PM
on Sep 14, 2016 11:44 PM

Please check Below Code for your reference. We sets display name for sender from where we sends an email.

protected void Page_Load(object sender, EventArgs e)
    if (!this.IsPostBack)
        this.SendEmail("", "Email Subject", "Your Email Body", "Your Display Name");

public void SendEmail(string fromEmailAddress, string subject, string body, string displayName)
    using (MailMessage mm = new MailMessage())
        // To set Email Id Which user has entered also if Display name is there the pass it as second parameter when assigning mm.From in new MailAddress. 
        // You can set sender's display name 
        mm.From = new MailAddress(fromEmailAddress, displayName);

        // It is receiver email Id which we assign in mm.To.
        mm.To.Add(new MailAddress(""));

        // Subject which you sets from Email
        mm.Subject = subject;

        // Body which Sets for Email
        mm.Body = body;

        mm.IsBodyHtml = true;
        SmtpClient smtp = new SmtpClient();

        // Your Account details which you are going to Send Email from Application            
        smtp.Host = "";
        smtp.EnableSsl = true;
        System.Net.NetworkCredential networkCred = new System.Net.NetworkCredential();
        networkCred.UserName = fromEmailAddress;
        networkCred.Password = "your gmail password";
        smtp.UseDefaultCredentials = true;
        smtp.Credentials = networkCred;
        smtp.Port = 587;


on Sep 16, 2016 12:17 AM

Thanks a lot Kalpesh sir for your prompt  reply.

on Sep 16, 2016 03:13 AM
Instead of saying thanks mark the reply or replies(if multiple) that helped as Answer.