如何将MailMessage与MFA一起使用或通过启用MFA发送电子邮件?
我正在使用asp.net制作一个应用程序,并且正在使用sytem.net.mail.mail.mailmessage
函数在添加新条目时发送电子邮件以发送电子邮件,但是我的业务正在其帐户上使用MFA 。我想知道,是否有任何方法可以规避MFA。无需首先将其禁用。
示例代码
MailAddress to = new MailAddress("[email protected]");
MailAddress from = new MailAddress("[email protected]");
MailMessage message = new MailMessage(from, to);
message.Subject = "New item added";
message.Body = "A new item has been added to the databse and is waiting approval.";
SmtpClient client = new SmtpClient("outlook.office365.com", 587)
{
Credentials = new NetworkCredential("[email protected]", "Password"),
EnableSsl = true
};
// code in brackets above needed if authentication required
try
{
client.Send(message);
}
catch (SmtpException ex)
{
Console.WriteLine(ex.ToString());
}
I am making an app with ASP.Net and I am using Sytem.Net.Mail.MailMessage
function to send emails when a new entry is added to the database, but my business is using MFA on its accounts. I was wondering, whether there is any way to circumvent MFA; without the need to disable it in the first place.
Example code
MailAddress to = new MailAddress("[email protected]");
MailAddress from = new MailAddress("[email protected]");
MailMessage message = new MailMessage(from, to);
message.Subject = "New item added";
message.Body = "A new item has been added to the databse and is waiting approval.";
SmtpClient client = new SmtpClient("outlook.office365.com", 587)
{
Credentials = new NetworkCredential("[email protected]", "Password"),
EnableSsl = true
};
// code in brackets above needed if authentication required
try
{
client.Send(message);
}
catch (SmtpException ex)
{
Console.WriteLine(ex.ToString());
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论