用smtpmail通过需要认证的smtp服务器发信
2004-07-06 09:51
417 查看
以前曾经碰到这个问题,没办法只好自己做了个类,用tcpclient建立连接,根据RFC821自己编码,差点没死掉。今天发现了更简单的办法!
MailMessage mail = new MailMessage();
mail.To = "me@mycompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.Body = "Some text goes here";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret"); //set your password here
SmtpMail.SmtpServer = "mail.mycompany.com"; //your real server goes here
SmtpMail.Send( mail );
MailMessage mail = new MailMessage();
mail.To = "me@mycompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.Body = "Some text goes here";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret"); //set your password here
SmtpMail.SmtpServer = "mail.mycompany.com"; //your real server goes here
SmtpMail.Send( mail );
相关文章推荐
- 用smtpmail通过需要认证的smtp服务器发信(C#)
- 在C#中如何通过需要用户认证的SMTP服务器发送Email
- 用Indy控件,通过需要简单认证的SMTP服务器,发送带附件的Email。
- 使用System.Web.Mail 组件通过SMTP认证发送邮件
- MailBee.NET Objects发送电子邮件(SMTP)教程一:使用SMTP服务器发送消息
- 转贴:怎么用java发送邮件一及通过smtp的认证
- c#发送需要smtp认证的邮件
- ubuntu16.04 heirloom-mailx 通过外部SMTP服务器发送邮件
- System.Net.Mail.SmtpException: 参数或变量中有语法错误。 服务器响应为:????exmail.qq.com???????
- centos 邮件服务 腾讯企业邮箱(免费) 使用iRedmail 需要有公网的centos主机 发邮件协议:smtp 端口25 收邮件协议:pop3 端口110 iredmail安装配置 使用邮箱系统 第三十一节课
- SMTP 服务器要求安全连接或客户端未通过身份验证的各个解决方案(C#)
- Oracle PLSQL通过SMTP发送E-MAIL邮件代码
- 无法通过远程桌面登录服务器,并提示需要提供许可证的问题解决
- 通过本地IIS SMTP服务器发送邮件时提示“邮箱不可用”的解决办法
- python qq邮箱的SMTP服务器需要身份验证
- 让微软企业库中的Email Trace Listener使用需要身份验证的SMTP服务器
- Dell 原有PowerEdge 服务器型号获得通过 Red Hat Enterprise Linux 6 认证
- 无法连接到服务器。 帐户: 'mail.bb.cn', 服务器: '*******', 协议: SMTP, 端口: 25, 安全(SSL): 否, 套接字错误: 10061, 错误号: 0x800CCC0E
- Java实现通过smtp服务器向指定邮箱发送邮件
- MailBee.NET Objects发送电子邮件(SMTP)教程八:使用多个SMTP服务器发送邮件