本文介绍了如何在asp.net中自动发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何在asp.net4.0中使用webservice自动向其他人发送邮件
您能帮忙编码吗?
谢谢,
I want know, how to send a mail automatically to other using webservice in asp.net4.0
could u help with coding ...
Thanks,
推荐答案
try
{
MailMessage mM = new MailMessage();
mM.From = new MailAddress("final_project_youssef@hotmail.com");
mM.To.Add("final_project_youssef@hotmail.com");
mM.Subject = "your subject line will go here";
//mM.Attachments.Add(new Attachment(@"C:\\attachedfile.jpg"));
mM.Body = reContactUs.Text;
mM.IsBodyHtml = true;
SmtpClient sC = new SmtpClient("smtp.live.com");//this is the smtp of hotmail
//port number for Hot mail
sC.Port = 25;
sC.Credentials = new NetworkCredential("your Email@hotmail.com", "password");
sC.EnableSsl = true;
sC.Send(mM);
}
catch (Exception ex)
{
throw ex;
}
private static void SendEmail(MailAddress fromAddress, MailAddress toAddress, string subject, string body)
{
var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
};
var client = new SmtpClient("smtpServerName");
client.Send(message);
}
这篇关于如何在asp.net中自动发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!