0
WebMail.Send(to: "someone@somewhere.com", subject: "email subject", body: "message body, isBodyHtml: false );

WebMail.SmtpServer = "smtp.gmail.com";
WebMail.SmtpPort = 587;
WebMail.EnableSsl = true;
WebMail.UserName = "me@mydomain.com";
WebMail.Password = "the password";
WebMail.From = "me@mydomain.com";

By using the above method, I am receiving email from sender name as "me@mydomain.com".. I tried changing the parameters "userName" and "From", but the gmail server rejects the message.

What parameter to add to receive email from a sender name instead of email id..

Gautam Sharma
  • 65
  • 1
  • 7

1 Answers1

0

try this:

System.Web.Mail is not a full .NET native implementation of the SMTP protocol. Instead, it uses the pre-existing COM functionality in CDONTS. System.Net.Mail, in contrast, is a fully managed implementation of an SMTP client.

So In MailAddress From = new MailAddress(FromName, FromName);

                                        ^

From = Gets or sets the e-mail address of the sender

Source

Community
  • 1
  • 1
Dgan
  • 10,077
  • 1
  • 29
  • 51