使用smtp服务器通过asp.net发送电子邮件 [英] Send email with asp.net by using smtp server
本文介绍了使用smtp服务器通过asp.net发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用smtp服务器通过asp.net发送电子邮件...?请任何人都可以帮助我解决它的紧急问题
How to Send email with asp.net by using smtp server....? pleasae anyone can help me its urgent
推荐答案
^ ]
http://bradkingsley.com/sending-email-from-asp-net -4-c-sample-code/ [
http://sqldecode.blogspot.in/2012/04/sending-email-in-aspnet-using-smtp.html[^]
http://bradkingsley.com/sending-email-from-asp-net-4-c-sample-code/[^]
using this link u will get much better information
添加名称空间
Add namespace
using System.Net.Mail;
代码:
MailMessage myMail = new MailMessage();
SmtpClient smtpclient = new SmtpClient();
MailAddress fromadrress = new MailAddress("from mail address");
myMail.From = fromadrress;
myMail.Subject = "Your subject";
myMail.Body = "Your email Body content";
myMail.To.Add("To email address");
myMail.Attachments.Add("File path");
smtpclient.Host = "smtp.gmail.com";
smtpclient.Port = 587;
smtpclient.EnableSsl = true;
smtpclient.Credentials = new system.Net.NetworkCredential("UserId","Password");
smtpclient.Send(myMail);
希望对您有帮助.
I hope it will helps you.
下面的代码用于发送电子邮件.
Code below is for sending Email.
string email = "email@email.com";
MailMessage ml = new MailMessage();
ml.From = new MailAddress("from@email.com");
ml.To.Add(new MailAddress(email));
ml.Subject = "Subject of email";
ml.Body = "Body of email";
ml.Priority = MailPriority.High;
ml.IsBodyHtml = false;
SmtpClient smtpClnt = new SmtpClient();
smtpClnt.Host = "SMTP Address";
smtpClnt.Send(ml);
这篇关于使用smtp服务器通过asp.net发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文