在 .NET 中发送邮件

发布于 2024-09-27 10:14:32 字数 85 浏览 0 评论 0原文

每个人! 我正在尝试在 ASP.NET 网站中发送邮件。我在 web.config 文件中有 smtp 配置部分。我如何配置它以将邮件从每个人发送给每个人?

everyone!
I'm trying to send mail in ASP.NET web-site. I have smtp configuration section in web.config file. How can I configure it to send mail from everyone to everyone?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

唔猫 2024-10-04 10:14:32

您不需要在 web.config 中添加任何内容,因为可以在 SmtpClient 构造函数。
然后,如果您需要身份验证,可以指定 NetworkCredential 以及 MailMessage 对象中的消息。
例子:

var client = new SmtpClient(smtpHost);
client.Credentials = new NetworkCredential(username, password);
var message = new MailMessage(from, to, subject, body);

client.Send(m);

You don't need to have anything in web.config as que SMTP server can be specified in the SmtpClient constructor.
Then, if you need authentication, you can specify a NetworkCredential and the message in a MailMessage object.
Example:

var client = new SmtpClient(smtpHost);
client.Credentials = new NetworkCredential(username, password);
var message = new MailMessage(from, to, subject, body);

client.Send(m);
心意如水 2024-10-04 10:14:32

这是您要找的吗?

SmtpMail.Send("From","To","Subject","Message");

只需指定“发件人”和“收件人”电子邮件地址即可。

SmtpMail 可以在 System.Web.Mail 中找到。

Is this what you're looking for?

SmtpMail.Send("From","To","Subject","Message");

Just specify the From and To email addresses and you're set.

SmtpMail can be found in System.Web.Mail.

倾`听者〃 2024-10-04 10:14:32

你的问题有点模糊。

如果您想从“每个人”发送它,那么您始终需要为每条消息指定不同的 FROM 参数。您不想在 .config 文件中设置 FROM 值。

如果您正在寻找代码示例,我鼓励您访问我的网站 www.SystemNetMail.com

Your question is a bit vague.

If you want to send it from "everyone", then you will always need to specify a different FROM parameter for every message. You do not want to set the FROM value in the .config file.

If you are looking for code examples, I encourage you to check out my site at www.SystemNetMail.com.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文