简体   繁体   English

是否可以使用C#中的昵称从Google Apps发送电子邮件

[英]Is it possible to send email from Google Apps from a Nickname in C#

I have a standard Google Apps account and they host my email for me.. 我有一个标准的Google Apps帐户,他们为我托管了我的电子邮件。

Currently I can send emails in C# code, but they always come from my main email address.. I have a couple of nicknames setup... and in the Gmail interface, its possible as descibed here : Google Apps - Send email from a nickname 目前,我可以使用C#代码发送电子邮件,但它们始终来自我的主要电子邮件地址。.我有几个昵称设置...并且在Gmail界面中,可能如下所示: Google Apps- 从昵称发送电子邮件

But I want to do this from code.. so I can send emails as "info@" or "support@"... I have an appSetting called "EmailFrom" that is defined as "info@"... 但是我想从代码中执行此操作。所以我可以以“ info @”或“ support @”的形式发送电子邮件。我有一个名为“ EmailFrom”的appSetting,定义为“ info @”。

MailMessage mm = new MailMessage(ConfigurationManager.AppSettings["EmailFrom"], ToAddress);

//'(2) Assign the MailMessage's properties
mm.Subject = Subject;
mm.Body = MessageBody;
mm.IsBodyHtml = true;

//'(3) Create the SmtpClient object
SmtpClient smtp = new SmtpClient();

smtp.Port = System.Convert.ToInt32(ConfigurationManager.AppSettings["smtpPort"]);
smtp.EnableSsl = true;

smtp.Send(mm);

Is that possible? 那可能吗?

Ok.. 好..

Figured it out... 弄清楚了...

It would seem that I needed to add the email address in the gmail interface... Select the Settings menu, and choose Accounts.... then select "Add another email address you own".. I just went through the verification process adding in the nickname I wanted to send from.. 看来我需要在gmail界面中添加电子邮件地址...选择“设置”菜单,然后选择“帐户....”,然后选择“添加您拥有的另一个电子邮件地址”。.我刚刚完成了验证过程我要发送的昵称..

Easy.. 简单..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM