如何从地址设置为(发送电子邮件的.NET通过Gmail)的任何邮件其他Gmail? [英] How to set From Address to any email other gmail in ( Sending Email in .NET Through Gmail )?

查看:179
本文介绍了如何从地址设置为(发送电子邮件的.NET通过Gmail)的任何邮件其他Gmail?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这个岗位发送电子邮件的.NET通过Gmail 我们有一个code到通过Gmail发送电子邮件,在发送邮件,我们从现场发现包含我用
Gmail帐户 我用的是相同的code,但通过更改发件人地址的任何电子邮件,我要在凭证为波纹管ANS组的Gmail地址

In this post Sending Email in .NET Through Gmail we have a code to send email through gmail, in the send mail we find from Field contain gmail account that I used
I use the same code but by changing the From Address to any email I want ans set gmail address in Credentials as bellow

var fromAddress = new MailAddress("AnyEmai@mailserver.com", "From Name");
var toAddress = new MailAddress("to@example.com", "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("from@gmail.com", fromPassword)
           };
using (var message = new MailMessage(fromAddress, toAddress)
                     {
                         Subject = subject,
                         Body = body
                     })
{
    smtp.Send(message);
}

但在发送的电子邮件Gmail帐户仍出现在从地址和 AnyEmai@mailserver.com 没有出现......有没有办法做到这一点?

But in the sent email gmail account still appear in From Address and AnyEmai@mailserver.com not appear ... is there any way to do that ?

推荐答案

难道你检查这个问题,<一个href="http://stackoverflow.com/questions/3871577/change-sender-address-when-sending-mail-through-gmail-in-c">change发件人地址通过Gmail在C#中发送电子邮件
时 我认为这是有关您的垂询!

Shall you check this question change sender address when sending mail through gmail in c#
I think it is related to your inquiry.

这篇关于如何从地址设置为(发送电子邮件的.NET通过Gmail)的任何邮件其他Gmail?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆