关于邮件发送

YYKXQ 2005-09-04 07:14:52
MailMessage mm=new MailMessage();

mm.From="lixun007@163.net";
mm.To="Bill@Microsoft.com";
mm.Subject="收到了回个话";
mm.Body="为什么Smtp类的Server属性不提供口令验证";
mm.Attachments.Add(new MailAttachment("c:\\test.txt"));
//Attachments实现IList接口,可以添加多个附件

SmtpMail.SmtpServer="webmail.careland.com.cn";
//设置发送邮件的Smtp服务器,目前没有提供需要身份验证的服务器的登陆方法
//比如163.net,163.com都不行,目前我的是我公司的SMTP服务器
//看看大伙有没有更好的办法
SmtpMail.Send(mm);
MessageBox.Show("OK");
...全文
194 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
fanbl 2005-09-05
  • 打赏
  • 举报
回复
这个用户名和密码就是你电子邮件的用户名和密码.我使用163的没有问题.
YYKXQ 2005-09-05
  • 打赏
  • 举报
回复
weisunding(鼎鼎)

Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1" ); //basic authentication
Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", txtUserName.Text ); //set your username here
Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", txtPassword.Text ); //set your password here

这个用户名和密码,我是不是要去这个网站注册?用户名和密码,如何获得?
zhongwanli 2005-09-04
  • 打赏
  • 举报
回复
MARK
TechEye 2005-09-04
  • 打赏
  • 举报
回复
MailMessage Message = new MailMessage();

Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1" ); //basic authentication
Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", txtUserName.Text ); //set your username here
Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", txtPassword.Text ); //set your password here

Message.To = txtTo.Text;
Message.Cc = txtCC.Text;
Message.Bcc = txtBCC.Text;
Message.From = txtFrom.Text;
Message.Subject = txtSubject.Text;
Message.BodyFormat = (MailFormat)System.Enum.Parse(typeof(MailFormat), ddlMailFormat.SelectedValue );
Message.Body = txtMessage.Text;

SmtpMail.SmtpServer = txtServer.Text;
SmtpMail.Send(Message);
TechEye 2005-09-04
  • 打赏
  • 举报
回复
可以的,加入如下代码

mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");

mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", @"××\××");

mm.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "××");

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧