在這篇文章中Sending Email in .NET Through Gmail我們有一個通過gmail發送郵件的代碼,在發送郵件中我們從字段中找到包含我使用的gmail帳戶
我使用相同的代碼,但通過將發件人地址更改爲我想要的任何電子郵件在證書的Gmail地址爲波紋管如何將地址設置爲其他Gmail中的任何電子郵件(通過Gmail通過.NET發送電子郵件)?
var fromAddress = new MailAddress("[email protected]", "From Name");
var toAddress = new MailAddress("[email protected]", "To Name");
const string fromPassword = "fromPassword";
const string subject = "Subject";
const string body = "Body";
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential("[email protected]", fromPassword)
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message);
}
但在發送的電子郵件Gmail帳戶仍出現在發件人地址和[email protected]
沒有出現......有沒有辦法做到這一點?