try to run Internet Service Manager, right click on Default SMTP virtual server, go to Access tab, click on "Relay.." button, add localhost or 127.0.0.1 to the relay list
收到的信息如下:不知道那个是Smtp服务器地址:Return-Path: <[email protected]> Delivered-To: [email protected] Received: (qmail 27043 invoked from network); 27 May 2003 03:01:54 -0000 Received: from unknown (HELO ghj1976) (219.238.254.18) by 0 with SMTP; 27 May 2003 03:01:54 -0000 Received: from mail pickup service by ghj1976 with Microsoft SMTPSVC; Tue, 27 May 2003 10:41:25 +0800 thread-index: AcMj+XYERVO8efZqRcGhBpvURGD+lQ== Thread-Topic: =?gb2312?B?Y2VzZ3Wy4svZ?= From: <[email protected]> To: <[email protected]> Subject: =?gb2312?B?Y2VzZ3Wy4svZ?= Date: Tue, 27 May 2003 10:41:25 +0800 Message-ID: <000001c323f9$774efd00$3305a8c0@ghj1976> MIME-Version: 1.0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: 8bit X-Mailer: Microsoft CDO for Exchange 2000 Content-Class: urn:content-classes:message Importance: low Priority: normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-OriginalArrivalTime: 27 May 2003 02:41:25.0901 (UTC) FILETIME=[77B9F3D0:01C323F9]你好 我把 SmtpMail.SmtpServer = "ghj1976" asp.net还是不行。 Exception Details: System.Runtime.InteropServices.COMException: 与服务器的传输连接失败。 win 下也有错误:Additional information: Could not access 'CDO.Message' object.
你把邮件服务器指定了试试,我的程序怎么没报这个错阿?你要不看看?跟你的差不多。
private void send_Click(object sender, System.EventArgs e)
{
string ServerStr ="mail.oildigital.com";
try
{
SmtpMail.SmtpServer = ServerStr;
MailMessage aMessage = new MailMessage ( ) ;
//新建一个MailMessage对象
aMessage.From = TBfrom.Text ;
//定义发信人地址,如果是多人,可以用","分开
aMessage.To = LBto.Text ;
//定义收信人地址,如果是多人,可以用","分开
aMessage.Cc = CCTextBox.Text ;
//定义抄送人地址,如果是多人,可以用","分开
aMessage.Bcc = BCCTextBox.Text ;
//定义暗送人地址,如果是多人,可以用","分开
aMessage.Subject = SubjectTextBox.Text ;
//定义邮件的主题
aMessage.Body = TBbody.Text ;
//定义邮件的内容
if ( AttachmentTextBox.Text.Length > 0 )
aMessage.Attachments.Add ( new MailAttachment ( AttachmentTextBox.Text.Trim() , MailEncoding.Base64 ) ) ;
//给邮件增加一个附件
SmtpMail.Send ( aMessage ) ;
Response.Write("<Script language=javaScript>alert('电子邮件已经发送到-> + LBto.Text !');</Script>"); }
catch ( Exception ex )
{
Response.Write("<Script language=javaScript>alert('发送失败!');</Script>");
} }
、、、、、、、、、、、、
private void BTNadd_Click(object sender, System.EventArgs e)//添加附件
{
AttachmentTextBoxa.Items.Add(Fadd.Value); AttachmentTextBox.Text=Fadd.Value;
}
你不可能忘加了吧?
AspNetPager 免费分页控件4.1版发布,欢迎下载使用:http://www.webdiyer.com
如果还不行,可以试试将自己的IP添加进上面那个允许中继栏里,然后将SmtpMail.SmtpServer改成相应的IP地址
不指明 SmtpMail.SmtpServer 或者指明为 localhost 是准备用本机的默认Smtp站点发Email。而不是其他的mail服务器。没有准备用其他的mail服务器。asp.net 程序:指定为下面方式。
SmtpMail.SmtpServer = "localhost";
SmtpMail.SmtpServer = "127.0.0.1";
SmtpMail.SmtpServer = "192.168.5.51"; //本机ip错误信息: 与服务器的传输连接失败。 指定为下面方式。
SmtpMail.SmtpServer = "";
//SmtpMail.SmtpServer = ""; 注释掉这一行。
错误信息: “SendUsing”配置值无效。 win 应用程序:指定为下面方式。
SmtpMail.SmtpServer = "localhost";
SmtpMail.SmtpServer = "127.0.0.1";
SmtpMail.SmtpServer = "192.168.5.51"; //本机ip错误信息:Could not access 'CDO.Message' object.指定为下面方式。
SmtpMail.SmtpServer = "";
//SmtpMail.SmtpServer = ""; 注释掉这一行。
发送成功,我可以收到Email;using System.Web.Mail;
你不可能忘加了吧?
不加这个就会编译错误,当然加了。改hosts文件,指成ip地址
没用呀。上面已经给出的都没有用。你是否启动了SMTP服务
不启动我win应用程序咋能把Email发送出去呀???把SmtpMail.Server设为""试试。
注释掉这一行,或者改为"" win应用程序都可以发送,但是asp.net程序就不可以发送,怪事。try to run Internet Service Manager, right click on Default SMTP virtual server, go to Access tab, click on "Relay.." button, add localhost or 127.0.0.1 to the relay list
思归的这种方法我查询以前帖子的时候就试过,没有用的。
如果还不行,可以试试将自己的IP添加进上面那个允许中继栏里,然后将SmtpMail.SmtpServer改成相应的IP地址你这方法就是思归的翻译,也没有用的。
有一个问题是你的IP是静态的吗?如果是拨号的动态IP,需要在上线后Reset你的IIS。
有一个问题是你的IP是静态的吗?如果是拨号的动态IP,需要在上线后Reset你的IIS。是静态ip。我在公司,不是拨号上网。
解决方法是:如果用smtp Server用外部的,请您把SendUsing设为2,内部设为1
搞定
反正我的cdo程序在 winapp和webapp中都是好的
Delivered-To: [email protected]
Received: (qmail 27043 invoked from network); 27 May 2003 03:01:54 -0000
Received: from unknown (HELO ghj1976) (219.238.254.18)
by 0 with SMTP; 27 May 2003 03:01:54 -0000
Received: from mail pickup service by ghj1976 with Microsoft SMTPSVC;
Tue, 27 May 2003 10:41:25 +0800
thread-index: AcMj+XYERVO8efZqRcGhBpvURGD+lQ==
Thread-Topic: =?gb2312?B?Y2VzZ3Wy4svZ?=
From: <[email protected]>
To: <[email protected]>
Subject: =?gb2312?B?Y2VzZ3Wy4svZ?=
Date: Tue, 27 May 2003 10:41:25 +0800
Message-ID: <000001c323f9$774efd00$3305a8c0@ghj1976>
MIME-Version: 1.0
Content-Type: text/plain;
charset="gb2312"
Content-Transfer-Encoding: 8bit
X-Mailer: Microsoft CDO for Exchange 2000
Content-Class: urn:content-classes:message
Importance: low
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
X-OriginalArrivalTime: 27 May 2003 02:41:25.0901 (UTC) FILETIME=[77B9F3D0:01C323F9]你好
我把
SmtpMail.SmtpServer = "ghj1976" asp.net还是不行。
Exception Details: System.Runtime.InteropServices.COMException: 与服务器的传输连接失败。
win 下也有错误:Additional information: Could not access 'CDO.Message' object.
解决方法是:如果用smtp Server用外部的,请您把SendUsing设为2,内部设为1
搞定
我这里不是使用的cdo ,是SmtpMail 不知道如何设置SendUsing
private static void SMTPSendMail(string strto,string strFrom,string strSubject,string strBody)
{
MailMessage myMail=new MailMessage();
myMail.From = strFrom;
myMail.To = strto;
myMail.Subject = strSubject;
myMail.Priority = MailPriority.Low;
myMail.BodyFormat = MailFormat.Text;
myMail.Body = strBody;
myMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 1;
//SmtpMail.SmtpServer="";
SmtpMail.Send(myMail);
}错误信息:
要求拾取目录路径,但未指定。 Exception Details: System.Runtime.InteropServices.COMException: 要求拾取目录路径,但未指定。 说明:myMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 1; 这样的代码只有 .net FramkWork 1.1 才支持,1.0 不支持。不知道如何修正??(asp.net下出现的这个错误,当然这时候 Win 应用程序没出错误。)
myMail.Fields.Update()但你上述问题应该不出在这,因为缺省值就是1.
你何有试下外部服务呢,把smtp.SmtpServer设为XXX.XXX.com这类的。
把sendusing设为2,
myMail.Fields.Update()下,然后再Send试试。
没有这个对象呀。不过我代码改成下面的方式,调用远程需要加密的mail服务器就没问题。但是调用本机的smtp服务一直有问题。
private static void SMTPSendMail(string strto,string strFrom,string strSubject,string strBody)
{
MailMessage myMail=new MailMessage();
myMail.From = strFrom;
myMail.To = strto;
myMail.Subject = strSubject;
myMail.Priority = MailPriority.Low;
myMail.BodyFormat = MailFormat.Text;
myMail.Body = strBody;
myMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"] = 2;
myMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendemailaddress"] = strFrom;
myMail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpaccountname"] = strFrom;
myMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = strFrom;
myMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = "需要验证的密码";
myMail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
myMail.Fields["http://schemas.microsoft.com/cdo/configuration/languagecode"] = 0x0804;
myMail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"] = "远程需要验证的mail服务器";
SmtpMail.Send(myMail);
}
你何有试下外部服务呢,把smtp.SmtpServer设为XXX.XXX.com这类的。
把sendusing设为2,
myMail.Fields.Update()下,然后再Send试试上面的代码就是使用的外部需要验证用户名、密码的mail服务器,发送没有问题。但是使用本机smtp发送。 就有问题 win可以发送,asp.net不可以发送。
mail.From="[email protected]";
mail.To=TextBox2.Text;
mail.Subject="您的密码";
mail.Body=Label4.Text;
mail.BodyFormat=MailFormat.Html;
// mail.BodyEncoding=MailFormat;
mail.Priority=MailPriority.High;
SmtpMail.Send(mail);
try
{
MailMessage aMessage = new MailMessage();
aMessage.From = Request.Form["ss_From"].ToString();
aMessage.To = Request.Form["ss_To"].ToString();
aMessage.Subject = Request.Form["ss_Subject"].ToString();
aMessage.Body = aSr.ReadToEnd();
aMessage.BodyFormat = MailFormat.Html;
SmtpMail.Send(aMessage);
Response.Redirect(Request.Form["ss_Redirect"].ToString());
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());//这句是刚才改的,不知道是否有错。
}***************************************************************************
以上是我的代码,肯定好用。注意IIS的Smtp必须打开,IP是合法的Internet地址。
我遇到过同样的问题
照你说的,我认为问题不在程序了。
我以前碰到过(不过不是ASP的)是Exchange的。
我在测试服务器上面运行都没问题,(没指定具体服务器,即用了本部本机服务器了)
但当我把程序移植到第二部机时,出错了,邮件发不出了。不过我后来是使用了外部服 务器(面向Internet)的服务器。sendusing=2,smtp="mail.XXX.com",就行了。
所以,我认为是服务器配置问题。