gpt4 book ai didi

c# - 从 SMTP 服务器发送邮件

转载 作者:行者123 更新时间:2023-12-01 13:39:57 24 4
gpt4 key购买 nike

我知道要从 SMTP 服务器发送电子邮件,需要服务器地址、密码和用户名/默认凭据。但是,SMTP 是否也有访问服务器本身的密码?还有用户名吗?

最佳答案

这是适合我的实现:

            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add("receiveremailaddress@xxx.com");
message.Subject = "This is the Subject line";
message.From = new MailAddress("youremailaddress@xxx.it", "Name to Display");
message.Body = "This is the message body";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("yoursmtphost");
smtp.Credentials = new NetworkCredential("youremailaddress@xxx.it", "yourpassword");
smtp.Send(message);

关于c# - 从 SMTP 服务器发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20915126/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com