mm.To = "xboy-punk2002@163.com";
mm.From = "xboypunk2002@163.com";
mm.Subject = "测试邮件";
mm.Body = "请注意查收";
try
{
SmtpMail.SmtpServer = "smtp.163.com";
SmtpMail.Send(mm);
Response.Write("发送成功");
}
catch(Exception ex)
{
Response.Write("发送失败"+ex.Message.ToString());
}
以上2个都是自己的油箱。每次都报:未能访问“CDO.Message”对象。
看网站代码有的写了3个FILEDS,是不是我3个FIELDS没写呢?
因为我不知道那3个FIELDS到底有什么作用。请高手将我程序修改后贴出来。
如果需要写FIELDS请写上注释好吗?谢谢!!!
6 个解决方案
#1
http://www.lenvo.cn/soft/JavaScript.pdf
#2
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",1);
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","sendusername");
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","sendpassword");
这3个是什么意思,主要是我一定得添写那个网址吗?1代表什么,后面的名称和密码知道是怎么回事了。这个网址有什么意义?请高手指教啊。
另外我什么都没配置,是不是要配置什么啊?
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","sendusername");
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","sendpassword");
这3个是什么意思,主要是我一定得添写那个网址吗?1代表什么,后面的名称和密码知道是怎么回事了。这个网址有什么意义?请高手指教啊。
另外我什么都没配置,是不是要配置什么啊?
#3
你用JMAIL试试吧,不要在一颗树上吊死呵呵
1.安装jmail4.3
2.找到jmail.dll(Program Files\Dimac\w3JMail4下)
3.执行Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Bin\ildasm.exe(可使用Visual Studio .Net 2003 命令提示),
格式如下:tlbimp c:\Program Files\Dimac\w3JMail4\jmail.dll /out:myJmail.dll /namespace:myJmail
就是我在Visual Studio .Net 2005命令提示下编译执行 tlbimp c:\Program Files\Dimac\w3JMail4\jmail.dll /out:myJmail.dll /namespace:myJmail
我的代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Mail;
using System.Web.Util;
using myJmail;
using Tool;
using Manager;
using Entity;
public partial class UserControls_Jmaill : System.Web.UI.UserControl
{
string strCurrentPath = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSend_Click(object sender, EventArgs e)
{
try
{
this.lblTitle.Text = "发送邮件控件";
myJmail.Message Jmail = new myJmail.Message();
DateTime t = DateTime.Now;
String Subject = this.txtTitle.Text;
String body = this.txtContent.Text;
String FromEmail = this.txtFormEmail.Text;//你的email
String ToEmail = this.txtToEmail.Text;//对方的email
String AddAttachment = this.FileUploadSubject.PostedFile.FileName;
//Silent属性:如果设置为true,JMail不会抛出例外错误. JMail. Send( () 会根据操作结果返回true或false
Jmail.Silent = true;
//Jmail创建的日志,前提loging属性设置为true
Jmail.Logging = true;
//字符集,缺省为"US-ASCII"
Jmail.Charset = "GB2312";
//信件的contentype. 缺省是"text/plain") : 字符串如果你以HTML格式发送邮件, 改为"text/html"即可。
Jmail.ContentType = "text/html";
//添加收件人
Jmail.AddRecipient(ToEmail, "", "");
Jmail.From = FromEmail;
//发件人邮件用户名
Jmail.MailServerUserName = FromEmail;
//发件人邮件密码
Jmail.MailServerPassWord = "kongwei";
//设置邮件标题
Jmail.Subject = Subject;
//邮件添加附件,(多附件的话,可以再加一条Jmail.AddAttachment( "c:\\test.jpg",true,null);)就可以搞定了。[注]:加了附件,讲把上面的Jmail.ContentType="text/html";删掉。否则会在邮件里出现乱码。
Jmail.AddAttachment(AddAttachment, true, null);
//邮件内容
Jmail.Body = body + t.ToString();
//Jmail发送的方法
Jmail.Send("smtp.163.com", false);
Jmail.Close();
}
catch (Exception ex)
{
this.lblMessage.Text = ex.Message;
}
}
1.安装jmail4.3
2.找到jmail.dll(Program Files\Dimac\w3JMail4下)
3.执行Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Bin\ildasm.exe(可使用Visual Studio .Net 2003 命令提示),
格式如下:tlbimp c:\Program Files\Dimac\w3JMail4\jmail.dll /out:myJmail.dll /namespace:myJmail
就是我在Visual Studio .Net 2005命令提示下编译执行 tlbimp c:\Program Files\Dimac\w3JMail4\jmail.dll /out:myJmail.dll /namespace:myJmail
我的代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Mail;
using System.Web.Util;
using myJmail;
using Tool;
using Manager;
using Entity;
public partial class UserControls_Jmaill : System.Web.UI.UserControl
{
string strCurrentPath = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSend_Click(object sender, EventArgs e)
{
try
{
this.lblTitle.Text = "发送邮件控件";
myJmail.Message Jmail = new myJmail.Message();
DateTime t = DateTime.Now;
String Subject = this.txtTitle.Text;
String body = this.txtContent.Text;
String FromEmail = this.txtFormEmail.Text;//你的email
String ToEmail = this.txtToEmail.Text;//对方的email
String AddAttachment = this.FileUploadSubject.PostedFile.FileName;
//Silent属性:如果设置为true,JMail不会抛出例外错误. JMail. Send( () 会根据操作结果返回true或false
Jmail.Silent = true;
//Jmail创建的日志,前提loging属性设置为true
Jmail.Logging = true;
//字符集,缺省为"US-ASCII"
Jmail.Charset = "GB2312";
//信件的contentype. 缺省是"text/plain") : 字符串如果你以HTML格式发送邮件, 改为"text/html"即可。
Jmail.ContentType = "text/html";
//添加收件人
Jmail.AddRecipient(ToEmail, "", "");
Jmail.From = FromEmail;
//发件人邮件用户名
Jmail.MailServerUserName = FromEmail;
//发件人邮件密码
Jmail.MailServerPassWord = "kongwei";
//设置邮件标题
Jmail.Subject = Subject;
//邮件添加附件,(多附件的话,可以再加一条Jmail.AddAttachment( "c:\\test.jpg",true,null);)就可以搞定了。[注]:加了附件,讲把上面的Jmail.ContentType="text/html";删掉。否则会在邮件里出现乱码。
Jmail.AddAttachment(AddAttachment, true, null);
//邮件内容
Jmail.Body = body + t.ToString();
//Jmail发送的方法
Jmail.Send("smtp.163.com", false);
Jmail.Close();
}
catch (Exception ex)
{
this.lblMessage.Text = ex.Message;
}
}
#4
需要身份验证 大多smtp都需要身份验证的,不使用身份验证的smtp恐怕成了垃圾邮件助推器!
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",1);
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","sendusername");
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","sendpassword");
是添加身份验证的用户名和密码!
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",1);
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","sendusername");
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","sendpassword");
是添加身份验证的用户名和密码!
#5
顶你个肺
#6
MailMessage message = new System.Net.Mail.MailMessage(from, to);
message.Subject = "hello";
message.Body = "nihao";
//附件
string file =@"c:\1.rar";
Attachment att = new Attachment(file, MediaTypeNames.Application.Octet);
ContentDisposition content = att.ContentDisposition;
content.CreationDate = System.IO.File.GetCreationTime(file);
content.ModificationDate = System.IO.File.GetLastWriteTime(file);
content.ReadDate = System.IO.File.GetLastAccessTime(file);
message.Attachments.Add(att);
// MailAddress copy = new MailAddress("admin@sina.com");
// message.CC.Add(copy);
SmtpClient client = new SmtpClient("smtp.tom.com", 25);
client.Credentials = new NetworkCredential("zjsru1021", "123456");
client.Send(message);
message.Subject = "hello";
message.Body = "nihao";
//附件
string file =@"c:\1.rar";
Attachment att = new Attachment(file, MediaTypeNames.Application.Octet);
ContentDisposition content = att.ContentDisposition;
content.CreationDate = System.IO.File.GetCreationTime(file);
content.ModificationDate = System.IO.File.GetLastWriteTime(file);
content.ReadDate = System.IO.File.GetLastAccessTime(file);
message.Attachments.Add(att);
// MailAddress copy = new MailAddress("admin@sina.com");
// message.CC.Add(copy);
SmtpClient client = new SmtpClient("smtp.tom.com", 25);
client.Credentials = new NetworkCredential("zjsru1021", "123456");
client.Send(message);
#1
http://www.lenvo.cn/soft/JavaScript.pdf
#2
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",1);
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","sendusername");
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","sendpassword");
这3个是什么意思,主要是我一定得添写那个网址吗?1代表什么,后面的名称和密码知道是怎么回事了。这个网址有什么意义?请高手指教啊。
另外我什么都没配置,是不是要配置什么啊?
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","sendusername");
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","sendpassword");
这3个是什么意思,主要是我一定得添写那个网址吗?1代表什么,后面的名称和密码知道是怎么回事了。这个网址有什么意义?请高手指教啊。
另外我什么都没配置,是不是要配置什么啊?
#3
你用JMAIL试试吧,不要在一颗树上吊死呵呵
1.安装jmail4.3
2.找到jmail.dll(Program Files\Dimac\w3JMail4下)
3.执行Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Bin\ildasm.exe(可使用Visual Studio .Net 2003 命令提示),
格式如下:tlbimp c:\Program Files\Dimac\w3JMail4\jmail.dll /out:myJmail.dll /namespace:myJmail
就是我在Visual Studio .Net 2005命令提示下编译执行 tlbimp c:\Program Files\Dimac\w3JMail4\jmail.dll /out:myJmail.dll /namespace:myJmail
我的代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Mail;
using System.Web.Util;
using myJmail;
using Tool;
using Manager;
using Entity;
public partial class UserControls_Jmaill : System.Web.UI.UserControl
{
string strCurrentPath = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSend_Click(object sender, EventArgs e)
{
try
{
this.lblTitle.Text = "发送邮件控件";
myJmail.Message Jmail = new myJmail.Message();
DateTime t = DateTime.Now;
String Subject = this.txtTitle.Text;
String body = this.txtContent.Text;
String FromEmail = this.txtFormEmail.Text;//你的email
String ToEmail = this.txtToEmail.Text;//对方的email
String AddAttachment = this.FileUploadSubject.PostedFile.FileName;
//Silent属性:如果设置为true,JMail不会抛出例外错误. JMail. Send( () 会根据操作结果返回true或false
Jmail.Silent = true;
//Jmail创建的日志,前提loging属性设置为true
Jmail.Logging = true;
//字符集,缺省为"US-ASCII"
Jmail.Charset = "GB2312";
//信件的contentype. 缺省是"text/plain") : 字符串如果你以HTML格式发送邮件, 改为"text/html"即可。
Jmail.ContentType = "text/html";
//添加收件人
Jmail.AddRecipient(ToEmail, "", "");
Jmail.From = FromEmail;
//发件人邮件用户名
Jmail.MailServerUserName = FromEmail;
//发件人邮件密码
Jmail.MailServerPassWord = "kongwei";
//设置邮件标题
Jmail.Subject = Subject;
//邮件添加附件,(多附件的话,可以再加一条Jmail.AddAttachment( "c:\\test.jpg",true,null);)就可以搞定了。[注]:加了附件,讲把上面的Jmail.ContentType="text/html";删掉。否则会在邮件里出现乱码。
Jmail.AddAttachment(AddAttachment, true, null);
//邮件内容
Jmail.Body = body + t.ToString();
//Jmail发送的方法
Jmail.Send("smtp.163.com", false);
Jmail.Close();
}
catch (Exception ex)
{
this.lblMessage.Text = ex.Message;
}
}
1.安装jmail4.3
2.找到jmail.dll(Program Files\Dimac\w3JMail4下)
3.执行Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Bin\ildasm.exe(可使用Visual Studio .Net 2003 命令提示),
格式如下:tlbimp c:\Program Files\Dimac\w3JMail4\jmail.dll /out:myJmail.dll /namespace:myJmail
就是我在Visual Studio .Net 2005命令提示下编译执行 tlbimp c:\Program Files\Dimac\w3JMail4\jmail.dll /out:myJmail.dll /namespace:myJmail
我的代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Mail;
using System.Web.Util;
using myJmail;
using Tool;
using Manager;
using Entity;
public partial class UserControls_Jmaill : System.Web.UI.UserControl
{
string strCurrentPath = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSend_Click(object sender, EventArgs e)
{
try
{
this.lblTitle.Text = "发送邮件控件";
myJmail.Message Jmail = new myJmail.Message();
DateTime t = DateTime.Now;
String Subject = this.txtTitle.Text;
String body = this.txtContent.Text;
String FromEmail = this.txtFormEmail.Text;//你的email
String ToEmail = this.txtToEmail.Text;//对方的email
String AddAttachment = this.FileUploadSubject.PostedFile.FileName;
//Silent属性:如果设置为true,JMail不会抛出例外错误. JMail. Send( () 会根据操作结果返回true或false
Jmail.Silent = true;
//Jmail创建的日志,前提loging属性设置为true
Jmail.Logging = true;
//字符集,缺省为"US-ASCII"
Jmail.Charset = "GB2312";
//信件的contentype. 缺省是"text/plain") : 字符串如果你以HTML格式发送邮件, 改为"text/html"即可。
Jmail.ContentType = "text/html";
//添加收件人
Jmail.AddRecipient(ToEmail, "", "");
Jmail.From = FromEmail;
//发件人邮件用户名
Jmail.MailServerUserName = FromEmail;
//发件人邮件密码
Jmail.MailServerPassWord = "kongwei";
//设置邮件标题
Jmail.Subject = Subject;
//邮件添加附件,(多附件的话,可以再加一条Jmail.AddAttachment( "c:\\test.jpg",true,null);)就可以搞定了。[注]:加了附件,讲把上面的Jmail.ContentType="text/html";删掉。否则会在邮件里出现乱码。
Jmail.AddAttachment(AddAttachment, true, null);
//邮件内容
Jmail.Body = body + t.ToString();
//Jmail发送的方法
Jmail.Send("smtp.163.com", false);
Jmail.Close();
}
catch (Exception ex)
{
this.lblMessage.Text = ex.Message;
}
}
#4
需要身份验证 大多smtp都需要身份验证的,不使用身份验证的smtp恐怕成了垃圾邮件助推器!
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",1);
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","sendusername");
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","sendpassword");
是添加身份验证的用户名和密码!
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",1);
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","sendusername");
mail1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","sendpassword");
是添加身份验证的用户名和密码!
#5
顶你个肺
#6
MailMessage message = new System.Net.Mail.MailMessage(from, to);
message.Subject = "hello";
message.Body = "nihao";
//附件
string file =@"c:\1.rar";
Attachment att = new Attachment(file, MediaTypeNames.Application.Octet);
ContentDisposition content = att.ContentDisposition;
content.CreationDate = System.IO.File.GetCreationTime(file);
content.ModificationDate = System.IO.File.GetLastWriteTime(file);
content.ReadDate = System.IO.File.GetLastAccessTime(file);
message.Attachments.Add(att);
// MailAddress copy = new MailAddress("admin@sina.com");
// message.CC.Add(copy);
SmtpClient client = new SmtpClient("smtp.tom.com", 25);
client.Credentials = new NetworkCredential("zjsru1021", "123456");
client.Send(message);
message.Subject = "hello";
message.Body = "nihao";
//附件
string file =@"c:\1.rar";
Attachment att = new Attachment(file, MediaTypeNames.Application.Octet);
ContentDisposition content = att.ContentDisposition;
content.CreationDate = System.IO.File.GetCreationTime(file);
content.ModificationDate = System.IO.File.GetLastWriteTime(file);
content.ReadDate = System.IO.File.GetLastAccessTime(file);
message.Attachments.Add(att);
// MailAddress copy = new MailAddress("admin@sina.com");
// message.CC.Add(copy);
SmtpClient client = new SmtpClient("smtp.tom.com", 25);
client.Credentials = new NetworkCredential("zjsru1021", "123456");
client.Send(message);