0

我有一个标准的 Google Apps 帐户,他们为我托管我的电子邮件..

目前我可以用 C# 代码发送电子邮件,但它们总是来自我的主要电子邮件地址。我设置了几个昵称...在 Gmail 界面中,它可能如下所述:Google Apps - 从昵称发送电子邮件

但我想从代码中做到这一点..所以我可以发送电子邮件为“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);

那可能吗?

4

1 回答 1

0

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..

Easy..

于 2013-01-15T01:40:00.417 回答