![](/img/trans.png)
[英]How to send an email from office365 account using domain windows authentication
[英]How to send email with attachment from Azure Web Site using office365 account
我有office 365帳戶,使用它我想在Azure網站中部署的Web應用程序中發送帶有附件的電子郵件。
這是這樣做的功能
public void SendEmailWithAttachment()
{
var objMailMessage = new MailMessage("EnterFromEmailAddress", "ReceiverEmailAddress")
{
Subject = "EnterEmailSubject",
IsBodyHtml = true,
Body = "EnterEmailBody"
};
//You can add more attachments
objMailMessage.Attachments.Add(new Attachment("EnterAttachmentLocationPath"));
var smtp = new SmtpClient("smtp.office365.com");
var login = new NetworkCredential("SenderEmail","SenderEmailPAssword");
smtp.Credentials = login;
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.Send(objMailMessage);
}
最好將web.config中的憑據或憑據保留為“應用程序設置”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.