1

I have difficult to change the "From" attribute value for the actual sender address, even I add it in the code, as below: (never mind what is added the From header shows my address, that I connect to SMTP server)

MailMessage m = new MailMessage(); 
SmtpClient sc = new SmtpClient();
m.From = new MailAddress(from, "Display name From"); 
m.To.Add(new MailAddress(to, "Display name To"));
m.Subject = "Test1"; 
m.IsBodyHtml = true; 
m.Body = " This is a Test Mail";
m.ReplyTo = new MailAddress(from);
MailAddress bcc = new MailAddress(to);
m.Bcc.Add(bcc);
sc.Host = "smtp.gmail.com"; 
sc.Port = 587;
sc.Credentials = new System.Net.NetworkCredential("google@gmail.com", "password");
sc.EnableSsl = true;
sc.Send(m);

I will appreciate if anybody will help me with the issue

4

1 回答 1

2

这是一个 gmail 问题,使用 gmail smtp(至少是非商业 gmail 帐户)时,您无法更改发件人地址。它总是将您的 gmail 地址设置为来自地址。

编辑:您可以将您在 gmail 设置中配置的地址用作“发送为”
https://support.google.com/a/answer/22370?hl=en

于 2013-10-09T07:50:55.467 回答