开发者

Sending mail in .NET

everyone! I'm tryin开发者_运维技巧g 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?


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);


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜