如何使用c#向godaddy office 365电子邮件发送邮件

如何使用c#向godaddy office 365电子邮件发送邮件

问题描述:

MailMessage mail = new MailMessage();

        mail.From = new MailAddress(txtEmail.Text.Trim());
        mail.To.Add("sshalemo@ad-betparkingservice.com");

        mail.Subject = txtSubject.Text.Trim();
        mail.IsBodyHtml = true;
        mail.Body = GetBody();

        

        //send the message
        SmtpClient smtpClient = new SmtpClient();
        smtpClient.Host = "smtpout.secureserver.net";//smtpout.secureserver.net relay-hosting.secureserver.net
        smtpClient.Port = 587;
        smtpClient.EnableSsl = true;
        smtpClient.UseDefaultCredentials = false;
        smtpClient.Credentials =
                  new NetworkCredential("sshalemo@ad-betparkingservice.com", "password");

        
        smtpClient.Timeout = 20000;
        smtpClient.Send(mail);





请帮帮我



Please help me

您好,因为您使用的是ASP.NET技术,所以不要浪费时间做C#基础事务。 ASP.NET是在.NET Framework上开发的,可帮助您编写更少的C#代码并在Internet上执行更多操作。



您可以使用ASP.NET代码将任何电子邮件服务提供商的电子邮件发送给互联网上的任何收件人。您只需使用从电子邮件服务提供商处获得的用户名和密码即可。此提供商的基本示例是Google Mail(Gmail)或Outlook,您可以使用其中任何一个,只需将您的用户名和密码传递给ASP.NET(以及更多参数和属性),您的电子邮件将使用一行代码。



代码非常简单,我已经在文章中介绍了这个,



使用ASP.NET助手轻松发送电子邮件 [ ^ ]



随意阅读,您将学习如何使用ASP.NET C#代码发送电子邮件。使用ASP.NET WebMail 类而不是使用旧的C#电子邮件发件人发送电子邮件真的非常有用且容易。
Hello, since you're using the ASP.NET technology, don't waste time doing C# base things. ASP.NET was developed over .NET Framework to help you write less C# code and do more on the Internet.

You can use the ASP.NET codes to send the emails using any email service provider to any recipient on the internet. You can just use the username and password that you get from the email service provider. Basic example of this provider is Google Mail (Gmail) or Outlook, you can use any of them and just pass the username and password of yours to the ASP.NET (along with some more parameters and properties) and your email will be sent using one line code.

The code is really very simple, I have already covered this in the Article,

Sending emails easily using ASP.NET helpers[^]

Feel free to read it, and you will learn how to send the emails using ASP.NET C# code. It is really very helpfull and easy to send the emails using ASP.NET WebMail class instead of using the old C# email sender.