Send Mail using C# code

using System.Net.Mail;

    public class MailHelp
{
public static void Send(string subject, string body)
{
MailMessage message = new MailMessage();
SmtpClient client = new SmtpClient();
client.Port = ;
client.Host = "smtphost.mycompany.com";
client.Timeout = ;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("user", "pwd","domain"); message.From = new MailAddress("from@server.com");
message.To.Add(new MailAddress("to@server.com"));
message.CC.Add(new MailAddress("cc@server.com"));
message.Subject = subject;
message.Body = body; client.Send(message);
}
}
上一篇:[翻译]ASP.NET Web API 2 中的全局错误处理


下一篇:unix的发展