asp文件发送邮件到邮箱的代码?
本人想填写信息成功后发送到邮箱 怎么弄啊? --------------------编程问答--------------------private void SendEmailToUser(string userName, string userEmail)
{
try
{
Email email = new Email();
string title = "欢迎" + userName + "加入XX网";
string str = "邮件内容";
email.STitle = title;
email.SUserName = userEmail;
email.SBody = str.ToString();
email.SendEmail();
}
catch
{
}
}
Email类
private string _sTitle;--------------------编程问答--------------------
public string STitle
{
get { return _sTitle; }
set { _sTitle = value; }
}
private string _sBody;
public string SBody
{
get { return _sBody; }
set { _sBody = value; }
}
private string _sUserName;
public string SUserName
{
get { return _sUserName; }
set { _sUserName = value; }
}
private string _stype;
public string Stype
{
get { return _stype; }
set { _stype = value; }
}
/// <summary>
/// 用户邮件发送
/// </summary>
/// <param name="Email">email地址</param>
/// <param name="title">邮件的标题</param>
/// <param name="body">邮件内容</param>
/// <returns></returns>
public void SendEmail()
{
bool b = false;
try
{
lock (this)
{
string userEmail = this.SUserName; string title = STitle; string body = SBody;
string smtpServer = "";
string userName = "";
string pwd = "";
if (userEmail.Contains("@sina"))
{
smtpServer = "smtp.sina.com.cn";
userName = "邮箱帐号";
pwd = "密码";
}
else if (userEmail.Contains("@qq"))
{
smtpServer = "smtp.qq.com";
userName = "邮箱帐号";
pwd = "密码";
}
。。。。。自己加各种邮箱
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
msg.SubjectEncoding = encoding;//邮件标题编码
msg.BodyEncoding = encoding;//邮件内容编码
msg.IsBodyHtml = true;//是否是HTML邮件
msg.Priority = System.Net.Mail.MailPriority.High;//邮件优先级
SmtpClient client = new SmtpClient(smtpServer, 25);
client.UseDefaultCredentials = true;
string _userName = userName;
client.Credentials = new System.Net.NetworkCredential(_userName, pwd);
client.DeliveryMethod = SmtpDeliveryMethod.Network;
msg.From = new MailAddress(userName, title, encoding);
msg.To.Add(userEmail);
msg.Subject = title;
msg.Body = body;
int add_emailID = 0;
if (Stype == "admin")
{
add_emailID = AddEmailrecord(userName, SUserName);
}
client.Send(msg);
if (Stype == "admin")
{
UpdateEmailState(add_emailID);
}
}
}
catch (Exception exp)
{
throw new Exception(exp.Message);
}
}
jmail.
第三方插件一大推 。度娘一下
sqlserver 系统函数 也可以
补充:.NET技术 , ASP.NET