c#如何发邮件?(转)
2006-01-18 14:39
169 查看
c#如何发邮件?
作者: 未知
日期:
easy, too easy;
--------------------code---------------------
private void sengmill_net()
{//.net smtp类进行邮件发送,支持认证,附件添加;
System.Web.Mail.MailMessage mailmsg = new System.Web.Mail.MailMessage();
mailmsg.From = this.tb_from.Text.Trim();
mailmsg.To = this.tb_to.Text.Trim();
mailmsg.Body = this.tb_mailBody.Text.Trim();
mailmsg.Subject = "test mail from hz";
/* 附件的粘贴, ^_^,笨了点;
if(this.att1.Value.ToString().Trim()!=string.Empty)
mailmsg.Attachments.Add(new System.Web.Mail.MailAttachment(this.att1.Value.ToString().Trim()));
if(this.att2.Value.ToString().Trim()!=string.Empty)
mailmsg.Attachments.Add(new System.Web.Mail.MailAttachment(this.att2.Value.ToString().Trim()));
if(this.att3.Value.ToString().Trim()!=string.Empty)
mailmsg.Attachments.Add(new System.Web.Mail.MailAttachment(this.att3.Value.ToString().Trim()));
*/
mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//是否需要验证,一般是要的
mailmsg.Fields.Add
("http://schemas.microsoft.com/cdo/configuration/sendusername", "gallon_han");
//自己邮箱的用户名
mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "218500");
//自己邮箱的密码
System.Web.Mail.SmtpMail.SmtpServer = this.tb_smtpserver.Text.Trim();
System.Web.Mail.SmtpMail.Send(mailmsg);}
作者: 未知
日期:
easy, too easy;
--------------------code---------------------
private void sengmill_net()
{//.net smtp类进行邮件发送,支持认证,附件添加;
System.Web.Mail.MailMessage mailmsg = new System.Web.Mail.MailMessage();
mailmsg.From = this.tb_from.Text.Trim();
mailmsg.To = this.tb_to.Text.Trim();
mailmsg.Body = this.tb_mailBody.Text.Trim();
mailmsg.Subject = "test mail from hz";
/* 附件的粘贴, ^_^,笨了点;
if(this.att1.Value.ToString().Trim()!=string.Empty)
mailmsg.Attachments.Add(new System.Web.Mail.MailAttachment(this.att1.Value.ToString().Trim()));
if(this.att2.Value.ToString().Trim()!=string.Empty)
mailmsg.Attachments.Add(new System.Web.Mail.MailAttachment(this.att2.Value.ToString().Trim()));
if(this.att3.Value.ToString().Trim()!=string.Empty)
mailmsg.Attachments.Add(new System.Web.Mail.MailAttachment(this.att3.Value.ToString().Trim()));
*/
mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//是否需要验证,一般是要的
mailmsg.Fields.Add
("http://schemas.microsoft.com/cdo/configuration/sendusername", "gallon_han");
//自己邮箱的用户名
mailmsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "218500");
//自己邮箱的密码
System.Web.Mail.SmtpMail.SmtpServer = this.tb_smtpserver.Text.Trim();
System.Web.Mail.SmtpMail.Send(mailmsg);}
相关文章推荐
- ios如何利用系统邮件发送邮件
- 如何将EML格式邮件导入notes数据库中
- 如何备份邮件
- 如何预防邮件炸弹
- 如何使用cdosys.dll实现发送邮件
- python - 如何通过GMail发送邮件:smtplib的使用
- 如何配置禅道管理自动发送通知邮件
- 如何在美国公司写project plan 邮件--以hadoop安装和Mahout数据分析为例子
- 邮件群发如何搭配其他平台有效营销
- C#积木模块ABC:13.如何在C#中发送邮件?
- 转帖:口碑网UED Team » 如何编写兼容各主流邮箱的HTML邮件
- 如何解决在关闭outlook express 时系统提示压缩邮件的问题
- 如何避免自己的邮件被当成垃圾邮件
- 如何解决企业邮件对国外的通信问题
- Nodejs 如何发送邮件(Gmail 和 126邮箱)
- 如何使用SAP发送邮件?
- 如何对EDM邮件的用户数据进行分类
- 如何配置邮件转发
- 如何通过Cmdlet批量删除包含特定主题或关键字的邮件