求一邮件发送方法程序?? 最好不利用远程smtp服务器的方法。需要能批量快速发送邮件。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 那你在自己的机器上架一个smtp服务器把。 例如:Foxmail里的特快专递是怎么发送的? http://www.microsoft.com/china/community/Column/27.mspx里面有几种方案 先注册一个jMail组件,免费的,你到网上搜一下public class jSendMail{ private string _creditUser; private string _creditPassword; private string _mailServer; /// <summary> /// 邮件服务器验证用户名 /// </summary> public string CreditUser { get{return _creditUser;} set{_creditUser = value;} } /// <summary> /// 邮件服务器验证用户密码 /// </summary> public string CreditPassword { get{return _creditPassword;} set{_creditPassword = value;} } /// <summary> /// 邮件服务器地址 /// </summary> public string SMTPServer { get{return _mailServer;} set{_mailServer = value;} } public jSendMail() { this.SMTPServer = "mxvip4.hichina.com"; } /// <summary> /// 发邮件 /// </summary> /// <param name="strFromUser">发件人地址</param> /// <param name="strToUser">收件人地址</param> /// <param name="strTitle">邮件标题</param> /// <param name="strContent">邮件正文</param> /// <param name="strFolderPath">附件文件夹的绝对路径</param> /// <returns></returns> public string SendMail(string strFromUser,string strToUser,string strSubject,string strContent,string strFolderPath) { jmail.MessageClass mail = new jmail.MessageClass(); mail.From = strFromUser; mail.AddRecipient(strToUser,"",""); mail.Subject = strSubject; mail.Body = strContent; mail.AddAttachment(strFolderPath,true,".doc"); mail.MailServerUserName = this.CreditUser; mail.MailServerPassWord = this.CreditPassword; try { bool f = mail.Send(this.SMTPServer,false); return "ok"; } catch(Exception ex) { return ex.Message; } }} 我调用System.Web.Mail.SmtpMail.Send方法,设置SmtpServer就出Exception,不设置SmtpServer(我本地的Smtp Serivce已经启动),程序可以运行,但目标邮箱收不到邮件。 采用CDONTS,程序可以正常运行,但目标邮箱也收不到邮件。 采用自己写的mailSender类,远程SMtp服务器短时间内只允许6次登陆。 public bool Send(string to, string from, string subject, string message) { try { MailMessage em = new MailMessage(); em.To = to; em.From = from; em.Subject = subject; em.Body = message; if(this.UserName != null && this.Password != null) { em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", this.UserName); //set your username here em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", this.Password); //set your password here } //SmtpMail.SmtpServer = this.SmtpServer; SmtpMail.SmtpServer = "smtp.126.com"; SmtpMail.Send(em); return true; } catch { return false; } } 请问,如何做插件 Winform 怎么实现离线数据库?(不联网,与SQL数据库断开状态下实现) vs2012,2010快捷键总是错乱 不知道怎么描述这个问题,winForm中DatagridView控件 控件的深度 求查詢後數據綁定方法,頂者有分 高手来看看。c#简单问题。 窗体间传值问题(winform) 请教一个Select数据库很奇怪的问题 Why RichTextBox not support BitMap format ?????? 请问以下类型到底是值类型还是引用类型? 怎样写一个功能齐备的书评数据库?我是新手,请帮忙介绍一些好的例子可以吗?多谢了各位大峡
public class jSendMail
{
private string _creditUser;
private string _creditPassword;
private string _mailServer; /// <summary>
/// 邮件服务器验证用户名
/// </summary>
public string CreditUser
{
get{return _creditUser;}
set{_creditUser = value;}
}
/// <summary>
/// 邮件服务器验证用户密码
/// </summary>
public string CreditPassword
{
get{return _creditPassword;}
set{_creditPassword = value;}
}
/// <summary>
/// 邮件服务器地址
/// </summary>
public string SMTPServer
{
get{return _mailServer;}
set{_mailServer = value;}
}
public jSendMail()
{
this.SMTPServer = "mxvip4.hichina.com";
}
/// <summary>
/// 发邮件
/// </summary>
/// <param name="strFromUser">发件人地址</param>
/// <param name="strToUser">收件人地址</param>
/// <param name="strTitle">邮件标题</param>
/// <param name="strContent">邮件正文</param>
/// <param name="strFolderPath">附件文件夹的绝对路径</param>
/// <returns></returns>
public string SendMail(string strFromUser,string strToUser,string strSubject,string strContent,string strFolderPath)
{
jmail.MessageClass mail = new jmail.MessageClass();
mail.From = strFromUser;
mail.AddRecipient(strToUser,"","");
mail.Subject = strSubject;
mail.Body = strContent;
mail.AddAttachment(strFolderPath,true,".doc");
mail.MailServerUserName = this.CreditUser;
mail.MailServerPassWord = this.CreditPassword;
try
{
bool f = mail.Send(this.SMTPServer,false);
return "ok";
}
catch(Exception ex)
{
return ex.Message;
}
}
}
采用CDONTS,程序可以正常运行,但目标邮箱也收不到邮件。
采用自己写的mailSender类,远程SMtp服务器短时间内只允许6次登陆。
if(this.UserName != null && this.Password != null) { em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", this.UserName); //set your username here em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", this.Password); //set your password here } //SmtpMail.SmtpServer = this.SmtpServer;
SmtpMail.SmtpServer = "smtp.126.com"; SmtpMail.Send(em); return true; } catch { return false; } }