用win2000自己的cdo也可以,SmtpMail.SmtpServer="localhost"; 改ip看看

解决方案 »

  1.   

    SmtpMail.SmtpServer = "mail.oildigital.com";
    你把邮件服务器指定了试试,我的程序怎么没报这个错阿?你要不看看?跟你的差不多。
    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;
    }
      

  2.   

    using System.Web.Mail;
    你不可能忘加了吧?
      

  3.   

    楼上的完全是在浪费CSDN的版面:-)
      

  4.   

    把SmtpMail.Server设为""试试。--------------------------------
    AspNetPager 免费分页控件4.1版发布,欢迎下载使用:http://www.webdiyer.com
      

  5.   

    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
      

  6.   

    IIS-------默认SMTP虚拟服务器---------属性-----------访问----------中继(按钮)-----选择最下面那个复选框
    如果还不行,可以试试将自己的IP添加进上面那个允许中继栏里,然后将SmtpMail.SmtpServer改成相应的IP地址
      

  7.   

    看来我没有说清楚,从新说明一下:
    不指明 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
    思归的这种方法我查询以前帖子的时候就试过,没有用的。
      

  8.   

    IIS-------默认SMTP虚拟服务器---------属性-----------访问----------中继(按钮)-----选择最下面那个复选框
    如果还不行,可以试试将自己的IP添加进上面那个允许中继栏里,然后将SmtpMail.SmtpServer改成相应的IP地址你这方法就是思归的翻译,也没有用的。
      

  9.   

    Asp.net里肯定能好用的,我原来做过,不过现在代码在家里。
    有一个问题是你的IP是静态的吗?如果是拨号的动态IP,需要在上线后Reset你的IIS。
      

  10.   

    Asp.net里肯定能好用的,我原来做过,不过现在代码在家里。
    有一个问题是你的IP是静态的吗?如果是拨号的动态IP,需要在上线后Reset你的IIS。是静态ip。我在公司,不是拨号上网。
      

  11.   

    Asp.net的我没有做过,不过我倒是解决过发邮件的这个问题。
    解决方法是:如果用smtp Server用外部的,请您把SendUsing设为2,内部设为1
    搞定
      

  12.   

    你检查一下你用win方式受到的email的属性,看看SMTP服务器地址是什么?
      

  13.   

    这个问题我就不看了,这么多高手都没有解决,懒得看了。
    反正我的cdo程序在 winapp和webapp中都是好的
      

  14.   

    收到的信息如下:不知道那个是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.
      

  15.   

    Asp.net的我没有做过,不过我倒是解决过发邮件的这个问题。
    解决方法是:如果用smtp Server用外部的,请您把SendUsing设为2,内部设为1
    搞定
    我这里不是使用的cdo ,是SmtpMail 不知道如何设置SendUsing
      

  16.   

    改成下面的代码,出现新的错误。
    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 应用程序没出错误。)
      

  17.   

    在设置sendusing后,务必加上下面一句。
    myMail.Fields.Update()但你上述问题应该不出在这,因为缺省值就是1.
    你何有试下外部服务呢,把smtp.SmtpServer设为XXX.XXX.com这类的。
    把sendusing设为2,
    myMail.Fields.Update()下,然后再Send试试。
      

  18.   

    myMail.Fields.Update()
    没有这个对象呀。不过我代码改成下面的方式,调用远程需要加密的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);    
    }
      

  19.   

    但你上述问题应该不出在这,因为缺省值就是1.
    你何有试下外部服务呢,把smtp.SmtpServer设为XXX.XXX.com这类的。
    把sendusing设为2,
    myMail.Fields.Update()下,然后再Send试试上面的代码就是使用的外部需要验证用户名、密码的mail服务器,发送没有问题。但是使用本机smtp发送。 就有问题 win可以发送,asp.net不可以发送。
      

  20.   

    试着不要用localhost,还有检查下DNS的配置
      

  21.   

    我也出现了同样的问题,不知道谁能正确的解答,谁解决了,给我发一份                                                 MailMessage    mail=new  MailMessage();  
                                                   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);  
      

  22.   

    to xuziling32(徐子陵32):我最后一次贴出的代码连接远程需要身份验证的mail服务器没有问题,你看看是不是有参考价值。 但是我连接本机smtp的一值有问题,还没有调试通过,
      

  23.   

    //发送邮件
    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地址。
      

  24.   

    我调用其他mail服务器也没有问题,不过调用本机默认smtp 就有问题,莫名其妙。Exception Details: System.Runtime.InteropServices.COMException: 要求拾取目录路径,但未指定。 
      

  25.   

    怀疑是本机Smtp设置问题,但是查了设置。都应该是对的呀。而且win应用程序调用没有问题。但是asp.net程序调用有问题。
      

  26.   

    是否ASP.NET的安全策略不允许访问某个跟发送邮件相关的对象?只是随便乱猜的。
      

  27.   

    to sumtec(Psydian)我也是这么猜得,但是找不到这是那个对象。
      

  28.   

    估计是iis的问题
    我遇到过同样的问题
      

  29.   

    那你试一下将用户从machine改成system(忘了是不是了,反正就是改一个用户名,这个以前有文章说过的)。至少可以证明是不是策略的问题。
      

  30.   

    你还是查下相关服务器吧。
    照你说的,我认为问题不在程序了。
    我以前碰到过(不过不是ASP的)是Exchange的。
        我在测试服务器上面运行都没问题,(没指定具体服务器,即用了本部本机服务器了)
         但当我把程序移植到第二部机时,出错了,邮件发不出了。不过我后来是使用了外部服 务器(面向Internet)的服务器。sendusing=2,smtp="mail.XXX.com",就行了。
    所以,我认为是服务器配置问题。