发送电子邮件时也会收到收件箱中的电子邮件

时间:2018-06-18 09:17:11

标签: c# gmail-api

为何从Gmail API发送电子邮件 一封电子邮件会发送到提供的电子邮件地址,我还会收到我的收件箱中的电子邮件?

public ActionResult NewEmail(String from, String text, string To, string sub)
{
    GmailService service = GmailServSendMail();
    string plainText = "To:" + To + "," + from + "\r\n" + "Subject:" + sub + "\r\n" + "Content-Type: text/html; charset=us-ascii\r\n\r\n" + text;
    var newMsg = new Google.Apis.Gmail.v1.Data.Message();
    newMsg.Raw = Base64UrlEncode(plainText.ToString());
    List<string> labe = new List<string>();
    labe.Add("SENT");
    newMsg.LabelIds = labe;
    service.Users.Messages.Send(newMsg, "me").Execute();
    return View("Email");
}

0 个答案:

没有答案