注册发送邮箱接口

//邮件
MailMessage objMailMessage = new MailMessage();
// 创建一个附件对象
//MailAttachment objMailAttachment = new MailAttachment(@"C:\Documents and Settings\Administrator\桌面\自己收藏的电影片目.txt"); //发送邮件的附件 (此处改成你自己电脑上存在的路径,在此我就把这行注释掉,怕你忘了改,到时运行不了!
//objMailMessage.Attachments.Add(objMailAttachment);//将附件附加到邮件消息对象中

// 创建邮件消息

objMailMessage.From = "testing_20110401@163.com";//源邮件地址 (一定要把此邮箱改成你自己常用的新浪邮箱,我的密码不方便告诉你,如有不明白的地方可加我Q:86017974,或给我发信件:hacker13A@163.com)
objMailMessage.To = email;//";//目的邮件地址,也就是发给我啦!
objMailMessage.Subject = "注册成功!";//发送邮件的标题
objMailMessage.Body = "Dear '"+n+"' Thank you for choosing GizmospringYour password: '"+p+"'You can use this password to log in our Design room where you can see the progress of your project, send us messages, chat with our representatives.Thank you once again for your interest. Please contact us with any questions. Best regards, Gizmospring.com Customer Service";//发送邮件的内容

//接着利用sina的SMTP来发送邮件,需要使用Microsoft .NET Framework SDK v1.1和它以上的版本
//基本权限
objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//用户名
objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "testing_20110401@163.com"); //这里是我自己的账号,为了给你们测试,我暂时不改密码,如果测试失败时,此处一定要改成你自己的邮箱地址和更改下面的密码,以及上面的源邮箱地址,objMailMessage.From = "liufeigeng@sina.com";如果不是用sina邮箱的话,服务器也得跟着改,就是这行代码也得改:SmtpMail.SmtpServer = "smtp.sina.com";
//密码
objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "123456"); //这是你用来发送邮件时用到的相应的邮箱密码,一定要记得改成你自己的邮箱密码.
//如果没有上述三行代码,则出现如下错误提示:服务器拒绝了一个或多个收件人地址。服务器响应为: 554 : Client host rejected: Access denied
//SMTP地址
SmtpMail.SmtpServer = "smtp.163.com"; //我用的是新浪的服务器,这些代码如果用在网易163的服务器,就是把:"smtp.sina.com"改为:"smtp.163.com",上面把:objMailMessage.From = "liufeigeng@sina.com";改成:objMailMessage.From = "liufeigeng@163.com";objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "liufeigeng@sina.com");这里的"liufeigeng@sina.com"改为:"liufeigeng@163.com"密码改为相应的密码,当然,这里得用你自己的邮箱,并且有一个问题就是,不能用刚申请的邮箱,不然会提示发送失败,要用有一定等级或积分的邮箱才能发送.
//开始发送邮件
SmtpMail.Send(objMailMessage);
//核心代码结束
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值