相关疑难解决方法(0)

如何在 ASP.NET 中使用具有 HTML 正文 + 附件的 GMAIL API 发送电子邮件

var msg = new AE.Net.Mail.MailMessage
              {
                  Subject = subject,
                  Body = bodyhtml,
                  From = new System.Net.Mail.MailAddress("myemail")

              };
            foreach (string add in vendorEmailList.Split(','))
            {
                if (string.IsNullOrEmpty(add))
                    continue;

                msg.To.Add(new System.Net.Mail.MailAddress(add));
            }

            msg.ReplyTo.Add(msg.From); // Bounces without this!!
            msg.ContentType = "text/html";

            ////attachment code

            foreach (string path in attachments)
            {
                var bytes = File.ReadAllBytes(path);
                string mimeType = MimeMapping.GetMimeMapping(path);
                AE.Net.Mail.Attachment attachment = new AE.Net.Mail.Attachment(bytes, mimeType, Path.GetFileName(path), true);
                msg.Attachments.Add(attachment);
            }
            ////end attachment code

            var msgStr = new StringWriter();
            msg.Save(msgStr);

            Message message = new Message();
            message.Raw = Base64UrlEncode(msgStr.ToString()); …
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net gmail-api

2
推荐指数
1
解决办法
4052
查看次数

标签 统计

.net ×1

asp.net ×1

c# ×1

gmail-api ×1