gpt4 book ai didi

asp.net - 从 localhost 在 ASP.NET 中发送电子邮件

转载 作者:行者123 更新时间:2023-12-02 18:27:31 27 4
gpt4 key购买 nike

我找到this发送邮件的解决方案,但它给了我错误。这是我的值(value)观:

Message to: anton_putov@mail.ru

Message from: anton_putov@mail.ru

subject: ....
.........

我使用的是 Visual Studio 2010。我必须设置任何配置属性或其他内容吗?

最佳答案

您使用什么类型的 SMTP?如果您没有自己的 SMTP 设置,则可以使用 Google Mail。下面是如何使用它。

MailMessage mail = new MailMessage();
mail.To.Add("Email ID where email is to be send");
mail.To.Add("Another Email ID where you wanna send same email");
mail.From = new MailAddress("YourGmailID@gmail.com");
mail.Subject = "Email using Gmail";

string Body = "Hi, this mail is to test sending mail"+
"using Gmail in ASP.NET";
mail.Body = Body;

mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential
("YourUserName@gmail.com","YourGmailPassword");
//Or your Smtp Email ID and Password
smtp.EnableSsl = true;
smtp.Send(mail);

关于asp.net - 从 localhost 在 ASP.NET 中发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13892339/

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