关于.net下email的几个问题? 发个帖子真难!不知道你们怎么样?我上午发的帖子,发完后找不到,到下午也没显示出来,我通过帖子管理,把帖子转到别处,再转回来,才出来!真让人气愤!搞不懂,怎么会有这种bug! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 原因在于mail.iholley.com要求用户认证(目前大部分都要求),而一开始我发现SmtpMail只能使用允许匿名用户的smtp服务器.在c#中我们仍然需要通过调用COM(CDO for Windows 2000)来完成用户认证的功能。 //在reference中添加CDO for Windows 2000 using CDO; public void SendEmail() { try { Configuration conf=new ConfigurationClass(); conf.Fields[CdoConfiguration.cdoSendUsingMethod].Value=CdoSendUsing.cdoSendUsingPort; conf.Fields[CdoConfiguration.cdoSMTPServer].Value="smtp.netease.com"; conf.Fields[CdoConfiguration.cdoSMTPServerPort].Value=25; conf.Fields[CdoConfiguration.cdoSMTPAccountName].Value="hydnoahark"; conf.Fields[CdoConfiguration.cdoSendUserReplyEmailAddress].Value="\"hydnoahark\" <[email protected]>"; conf.Fields[CdoConfiguration.cdoSendEmailAddress].Value="\"hydnoahark\" <[email protected]>"; conf.Fields[CdoConfiguration.cdoSMTPAuthenticate].Value=CdoProtocolsAuthentication.cdoBasic; conf.Fields[CdoConfiguration.cdoSendUserName].Value="hydnoahark"; conf.Fields[CdoConfiguration.cdoSendPassword].Value="xxx"; conf.Fields.Update(); MessageClass msg=new MessageClass(); msg.Configuration=conf; msg.To="[email protected]"; msg.Subject="Hello"; msg.TextBody="It's test"; msg.From="[email protected]"; msg.Send(); } catch(System.Runtime.InteropServices.COMException e) { MessageBox.Show(e.ToString()); } return; } 1.引自开心的文章,在asp.net下不用cdo也可以发信 如何通过需要验证的邮件服务器发送邮件? 在.NET Framework 推出以后,大家一直在为这个问题而伤脑筋。的确,在1.0的时候,我们是不能实现此方案的,大部分人选择了使用Socket底层自己重写。但是,在1.1的时候,其实Microsoft已经提供了验证功能了,只是一直没有公开。 恰好我在读.Text 0.95的源代码的时候找到了这段代码,感觉应该提供给大家 private void Page_Load(object sender, System.EventArgs e) { MailMessage mail = new MailMessage(); mail.To = "[email protected]"; mail.From = "[email protected]"; 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 ); } 参考资料: http://vaultpub.sourcegear.com/VaultService/VaultWeb/Blame.aspx?repid=7&path=$/Dottext/Dottext.Framework/Email/SystemMail.cs&version=1&includedversions=20 (用户名及密码为guest) 2.可以用用c#和jmail开发Asp.net的mail发送http://dev.csdn.net/develop/article/18/18794.shtm 但是这样要求自己要有个SMTP服务器,由于没有,自己试的时候一直没有成功.请参阅这里吧.http://www.microsoft.com/China/Community/program/originalarticles/TechDoc/sendmail.mspx .net使用jmail要把jmail组件引用下然后using jmail;就可以在代码中使用jmail发邮件了.如想要详细代码.message me! 谢谢几位的热心指点!asp.net 发邮件我已经写好可以使用!我问的不是这个问题:1、我是在发邮件的时候,怎么写收件人姓名? 例如:jmail的 msg.fromname="name" msg.addrecipient "email address","name"2、我用了using jmail ,也把jmail.dll作了引用,只是编译出错!不接受jmail 的参数,所以我想是我的错,还是我用的jmail.dll不对哪?to: tingchao(听潮) 但是这样要求自己要有个SMTP服务器,由于没有,自己试的时候一直没有成功.其实,用这种方式发邮件的时候,不用写SmtpMail.SmtpServer = "mail.mycompany.com";就可以执行,而且我在拨号的机器上调试也可以,只不过要打开smtp服务,但是接受到邮件的速度比较慢,在服务器上就很快,我想这种方式比较于邮件群发,不用担心smtp把你当作垃圾邮件! msg.From="(FromUserName) [email protected]"; 在对方的邮箱中的发件人就会显示出: FormUserName [email protected]^_^ .NET后台对接收“html代码”报错的处理? 下面是打印网页部分内容的代码,但是……,求解! 页面处理 菜鸟求助一SQL语句,谢谢了 写了一个简单的在线聊天,目前是以客户端来定时抽取服务器的数据,如何改进,主要代码如下: [150分]SharePoint里如何Transfer()? 请问在页面载入时,实现运行aspx页面的javascript还是.cs文件?另外。。。在线! 如何遍历容器控件中的自动生成文本框的值 我的一些电子书,要者给出能上传的ftp C#操作word的问题 动态生成控件的问题 vs.net
//在reference中添加CDO for Windows 2000
using CDO;
public void SendEmail()
{
try
{
Configuration conf=new ConfigurationClass();
conf.Fields[CdoConfiguration.cdoSendUsingMethod].Value=CdoSendUsing.cdoSendUsingPort;
conf.Fields[CdoConfiguration.cdoSMTPServer].Value="smtp.netease.com";
conf.Fields[CdoConfiguration.cdoSMTPServerPort].Value=25;
conf.Fields[CdoConfiguration.cdoSMTPAccountName].Value="hydnoahark";
conf.Fields[CdoConfiguration.cdoSendUserReplyEmailAddress].Value="\"hydnoahark\" <[email protected]>";
conf.Fields[CdoConfiguration.cdoSendEmailAddress].Value="\"hydnoahark\" <[email protected]>";
conf.Fields[CdoConfiguration.cdoSMTPAuthenticate].Value=CdoProtocolsAuthentication.cdoBasic;
conf.Fields[CdoConfiguration.cdoSendUserName].Value="hydnoahark";
conf.Fields[CdoConfiguration.cdoSendPassword].Value="xxx";
conf.Fields.Update();
MessageClass msg=new MessageClass();
msg.Configuration=conf;
msg.To="[email protected]";
msg.Subject="Hello";
msg.TextBody="It's test";
msg.From="[email protected]";
msg.Send();
}
catch(System.Runtime.InteropServices.COMException e)
{
MessageBox.Show(e.ToString());
}
return;
}
引自开心的文章,在asp.net下不用cdo也可以发信
如何通过需要验证的邮件服务器发送邮件? 在.NET Framework 推出以后,大家一直在为这个问题而伤脑筋。的确,在1.0的时候,我们是不能实现此方案的,大部分人选择了使用Socket底层自己重写。但是,在1.1的时候,其实Microsoft已经提供了验证功能了,只是一直没有公开。 恰好我在读.Text 0.95的源代码的时候找到了这段代码,感觉应该提供给大家 private void Page_Load(object sender, System.EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To = "[email protected]";
mail.From = "[email protected]";
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 );
}
参考资料: http://vaultpub.sourcegear.com/VaultService/VaultWeb/Blame.aspx?repid=7&path=$/Dottext/Dottext.Framework/Email/SystemMail.cs&version=1&includedversions=20 (用户名及密码为guest)
2.可以用
用c#和jmail开发Asp.net的mail发送
http://dev.csdn.net/develop/article/18/18794.shtm
就可以在代码中使用jmail发邮件了.如想要详细代码.message me!
asp.net 发邮件我已经写好可以使用!
我问的不是这个问题:
1、我是在发邮件的时候,怎么写收件人姓名?
例如:jmail的
msg.fromname="name"
msg.addrecipient "email address","name"
2、我用了using jmail ,也把jmail.dll作了引用,只是编译出错!不接受jmail 的参数,所以我想是我的错,还是我用的jmail.dll不对哪?to: tingchao(听潮)
但是这样要求自己要有个SMTP服务器,由于没有,自己试的时候一直没有成功.
其实,用这种方式发邮件的时候,不用写SmtpMail.SmtpServer = "mail.mycompany.com";
就可以执行,而且我在拨号的机器上调试也可以,只不过要打开smtp服务,但是接受到邮件的速度比较慢,在服务器上就很快,我想这种方式比较于邮件群发,不用担心smtp把你当作垃圾邮件!
在对方的邮箱中的发件人就会显示出: FormUserName [email protected]
^_^