我在C#的ASP.NET代码中使用Server.CreateObject方法生成一个COM组建的实例,但是Server.CreateObject方法返回一个Object类型,这样的话,只要我调用这个COM组件中非Object类型的方法,编译器就拒绝编译。如何才能转换这个对象的类型?我现在不想用Interop来调用COM组件,不知道在座的高手有没有可行的办法。重金酬谢

解决方案 »

  1.   

    ASP.NET里不用Server.CreateObject了。你在添加引用后,可以这样
    xxxClass  x= new xxxClass();
    x.Method();
      

  2.   

    参见http://www.yesky.com/20020508/1610074_1.shtml
      

  3.   

    情况是这样的:我在本地使用VS.NET 2003做的ASP.NET网页,我想使用JMail在网站上面发送邮件。但是JMail是一个COM组件,我的虚拟服务器和我本地都装了JMail,但是两个版本不同,我在这里用Interop做的DLL放到服务器上总是说找不到“SMTP”服务器。但是我原来ASP中使用CreateObject却能够正常发信,所以我想实施老办法。我查过代码了,没有什么问题
      

  4.   

    http://aspnet.4guysfromrolla.com/demos/printPage.aspx?path=/articles/010803-1.aspxhttp://www.aspheute.com/english/20000828.asp
    http://www.4guysfromrolla.com/ASPScripts/PrintPage.asp?REF=%2Fwebtech%2F112101%2D1%2Eshtml
      

  5.   

    http://www.a5d.com/infoview/Article_391.html
      

  6.   

    发送邮件参考这个
    http://www.sron.net/infoView/Article_657.html
      

  7.   

    http://www.csdn.com.cn/html/040601/2004525564010061.html
      

  8.   

    .NET组件我也用过了,但是服务器的SMTP要求身份验证的,那个组建没什么用处
      

  9.   

    //添加jmail引用
    using jmail; //添加命名空间try
    {
    if (SendTo.Text=="") { return; }
               
      jmail.MessageClass Jmail=new jmail.MessageClass();
      Jmail.Charset="GB2312";
      Jmail.Encoding="base64";
      Jmail.ContentType="text/html";  if (SendTo.Text!="")    {  Jmail.AddRecipient  (SendTo.Text,null,null);   }                  //目的地址
      if (SendCC.Text!="")   {  Jmail.AddRecipientCC (SendCC.Text,"","");  }                 //抄送地址 
      if (SendBCC.Text!="")   {  Jmail.AddRecipientBCC(SendBCC.Text,"");   }                     //密送地址
     if (SendFrom.Text!="")  {  Jmail.From= SendFrom.Text;     }                                //源地址
     if (SendTo.Text!="")    {  Jmail.Subject= MailTitle.Text; }
     if (Session["UserName"].ToString()!="") {Jmail.FromName=Session["UserName"].ToString(); }
     if (MailTitle.Text!="") {  Jmail.Subject=MailTitle.Text; }                                 // 主题
     if (MailInfor.Text!="") {  Jmail.Body = MailInfor.Text;        // 内容
    //---------------------------------- 附件 -------------------------
    String StrFileName;
    StrFileName= MailCylerder.PostedFile.FileName;
    //if (StrFileName.Length!=0)  {  Jmail.AddAttachment(StrFileName,false,"");}
     Jmail.AddAttachment(StrFileName,false,"");
    //-  -------------------------------------------------------------Jmail.Silent=true;
    Jmail.Logging=true;
          
    Jmail.MailServerUserName="UserName" ;
    Jmail.MailServerPassWord="Password" ;

    if(Jmail.Send("smtp.domain.com",false))
    {
      // 成功
    }
    else
    {
      // 发送失败
    }
    }
    catch
    {
      //异常
    }
      

  10.   

    .net自带的发送email组建也是可以带身份验证的: MailMessage ms=new MailMessage();
       ms.To="...";//发送给
       ms.Cc+="...";//抄送
       ms.From="";//发信人地址
       ms.Subject="title";//标题
       ms.Body="body";//正文
       ms.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");//是否需要身份验证
    ms.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",""); //用户名
    ms.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","");//密码
    SmtpMail.SmtpServer="61.55.138.186";//邮件服务器地址
    SmtpMail.Send(ms); //发送
      

  11.   

    to zpisgod:
    你的方法用过了,错误说服务器要求身份验证,我是拷贝粘贴的to luluso:
    你的方法也用了,错误信息:The message was undeliverable. All servers failed to receive the message 
      

  12.   

    这是非常郁闷的事.net在这方面限制死了不作引用就不能用