首页 > 解决方案 > 从 Godaddy 服务器上的 Office365 发送邮件

问题描述

对于一个应用程序,我正在用 c# 编写一个 api 服务。该站点托管在 Godaddy 服务器上。我们也有一个 Office 365 帐户。我正在尝试通过此帐户凭据在我的 c# 代码中发送 main 。之前我们有elasticemail smtp 帐户。相同的代码正在使用弹性电子邮件帐户。但此代码不适用于 Office 365 帐户。

smtpClient.Host = "smtp.office365.com";
                    smtpClient.EnableSsl = true;
                    smtpClient.Port = 25;
                    MailMessage message = new MailMessage();
                    MailAddress fromAddress = new MailAddress("my365email@domain.com");
                    MailAddress toAddress = new MailAddress("toaddress@yahoo.com");
                    smtpClient.Credentials = new System.Net.NetworkCredential("my365email@domain.com", "password");
                    message.From = fromAddress;
                    message.To.Add(toAddress);
                    message.Subject = "This is the subject line";
                    message.Body = "This is a test mail";
                    smtpClient.Send(message);

标签: c#asp.netemailsmtp

解决方案


推荐阅读