The "SendUsing" configuration value is invalid / HttpException (0x80004005): Could not access 'CDO.Message' object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lds

    The "SendUsing" configuration value is invalid / HttpException (0x80004005): Could not access 'CDO.Message' object

    I am getting the following error:

    The "SendUsing" configuration value is invalid.
    Description: An unhandled exception occurred during the execution of
    the current web request. Please review the stack trace for more
    information about the error and where it originated in the code.

    Exception Details: System.Runtime. InteropServices .COMException: The
    "SendUsing" configuration value is invalid.

    Source Error:

    An unhandled exception was generated during the execution of the
    current web request. Information regarding the origin and location of
    the exception can be identified using the exception stack trace below.


    Stack Trace:


    [COMException (0x80040220): The "SendUsing" configuration value is
    invalid.
    ]

    [TargetInvocatio nException: Exception has been thrown by the target of
    an invocation.]
    System.RuntimeT ype.InvokeDispM ethod(String name, BindingFlags
    invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
    Int32 culture, String[] namedParameters ) +0
    System.RuntimeT ype.InvokeMembe r(String name, BindingFlags
    invokeAttr, Binder binder, Object target, Object[] args,
    ParameterModifi er[] modifiers, CultureInfo culture, String[]
    namedParameters ) +473
    System.Web.Mail .LateBoundAcces sHelper.CallMet hod(Object obj, String
    methodName, Object[] args) +58

    [HttpException (0x80004005): Could not access 'CDO.Message' object.]
    System.Web.Mail .LateBoundAcces sHelper.CallMet hod(Object obj, String
    methodName, Object[] args) +113
    System.Web.Mail .CdoSysHelper.S end(MailMessage message) +1846
    System.Web.Mail .SmtpMail.Send( MailMessage message) +153
    CAWAA.E.NeedHel p.btnSubmit_Cli ck(Object sender, EventArgs e) +580
    System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108

    System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
    eventArgument) +57
    System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
    sourceControl, String eventArgument) +18
    System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
    +33
    System.Web.UI.P age.ProcessRequ estMain() +1292


    Here is the code:

    Dim objMailMessage As New MailMessage
    objMailMessage. BodyFormat = MailFormat.Html
    objMailMessage. From = "blabla@bla .ca"
    objMailMessage. Subject = "Form Title"
    objMailMessage. Body = strMessage

    If Len(strEmailFro m) > 0 Then
    strEmailTo += ";" & strEmailFrom
    End If

    objMailMessage. To = strEmailTo
    SmtpMail.SmtpSe rver = "127.0.0.1"
    SmtpMail.Send(o bjMailMessage)


    This works on our testing server which uses a network service, but it
    does not work on our production server which does not. Any ideas? I
    know about the FAQ site System.WEb.Mail , OH MY!, and we have tried all
    of their suggestions and none of them work.

  • sp3d2orbit

    #2
    Re: The "SendUsing " configuration value is invalid / HttpException (0x80004005): Could not access 'CDO.Message' object

    Smtp.SendUsing = 2

    Comment

    • lds

      #3
      Re: The "SendUsing " configuration value is invalid / HttpException (0x80004005): Could not access 'CDO.Message' object


      sp3d2orbit wrote:[color=blue]
      > Smtp.SendUsing = 2[/color]


      When I enter in the code you suggested it cannot be compiled in Visual
      Studio .NET 2003. it gives me the following error:

      Name 'smtp' is not declared

      I have imported System.Web.Mail only. Should I be importing something
      else as well?

      Comment

      • sp3d2orbit

        #4
        Re: The "SendUsing " configuration value is invalid / HttpException (0x80004005): Could not access 'CDO.Message' object

        If you upgrade to 2005 you probably won't have this problem. Here's a
        sample of sending email from .NET 2.0:

        MailMessage msg = new MailMessage();
        msg.From = new MailAddress("te st@test.com");
        msg.To.Add("tes t@test.com");
        msg.Subject = "test subject";
        msg.Body = "test body";

        SmtpClient smtp = new SmtpClient();
        smtp.Host = "smtp.yourdomai n.com";
        smtp.Send(msg);

        But, if you want to continue using CDO.Message (which MailMessage in <
        ..NET 2.0 wraps) you need to set the SendUsing property to 2. I have no
        idea how to set it from .NET but here's some sample C++ code to get you
        started:

        #import <msado15.dll> no_namespace rename("EOF", "adoEOF")
        #import <cdosys.dll> rename_namespac e("CDO") rename("EOF", "adoEOF")

        ....

        CDO::IMessagePt r pMail = NULL;
        pMail.CreateIns tance(__uuidof( CDO::Message));

        pMail->put_To("test@t est.com");
        pMail->put_From("test @test.com");
        pMail->put_Subject("t est subject");
        pMail->put_TextBody(" test body");

        CDO::IConfigura tionPtr pConfig(__uuido f(CDO::Configur ation));
        FieldsPtr pFields = pConfig->GetFields();
        pFields->Item["http://schemas.microso ft.com/cdo/configuration/smtpserver"]->Value

        =
        _variant_t("smt p.yourdomain.co m"); pFields->Item["http://schemas.microso ft.com/cdo/configuration/smtpserverport"]->Value
        = _variant_t((lon g)25);
        pFields->Item["http://schemas.microso ft.com/cdo/configuration/sendusing"]->Value
        = _variant_t(2);
        pFields->Update();

        pMail->Configuratio n = pConfig;
        pMail->Send();

        The most important line is the one that sets the SendUsing property to
        2.

        Best of luck,
        Matt Furnari

        Comment

        • sp3d2orbit

          #5
          Re: The &quot;SendUsing &quot; configuration value is invalid / HttpException (0x80004005): Could not access 'CDO.Message' object

          OK, here's some c# code that works for me.

          MailMessage msg = new MailMessage();
          msg.To = "test@test.com" ;
          msg.From = "test@test.com" ;
          msg.Subject = "test subject";
          msg.Body = "test body";
          msg.Fields["http://schemas.microso ft.com/cdo/configuration/smtpserverport"]
          = 25;
          msg.Fields["http://schemas.microso ft.com/cdo/configuration/smtpserver"]
          = "smtp.yourdomai n.com";
          msg.Fields["http://schemas.microso ft.com/cdo/configuration/sendusing"]
          = 2;
          SmtpMail.SmtpSe rver = "smtp.yourdomai n.com";
          SmtpMail.Send(m sg);

          Translating it into VB should be as simple as changing the first line.
          Sorry it tooks so long, I'm normally a c++ developer not a .NET
          developer.

          Best of luck,

          Matt Furnari

          Comment

          • Greg Burns

            #6
            Re: The &quot;SendUsing &quot; configuration value is invalid / HttpException (0x80004005): Could not access 'CDO.Message' object

            Sure this won't matter, but I use:

            SmtpMail.SmtpSe rver = "localhost"

            Is your SMTP server configured and working on your production server?

            Have you added 127.0.0.1 to the unresticted list for relaying? (AFAIR, I ran
            into this problem when I switched from Win2K to WinXP for my development
            machine). Not sure if the same thing applies for Win2003 Server or not....

            IIS->Default SMTP->Properties->Access tab->Relay button.

            Greg


            "lds" <lisa.staples@g nb.ca> wrote in message
            news:1131132191 .236688.142450@ g47g2000cwa.goo glegroups.com.. .[color=blue]
            >I am getting the following error:
            >
            > The "SendUsing" configuration value is invalid.
            > Description: An unhandled exception occurred during the execution of
            > the current web request. Please review the stack trace for more
            > information about the error and where it originated in the code.
            >
            > Exception Details: System.Runtime. InteropServices .COMException: The
            > "SendUsing" configuration value is invalid.
            >
            > Source Error:
            >
            > An unhandled exception was generated during the execution of the
            > current web request. Information regarding the origin and location of
            > the exception can be identified using the exception stack trace below.
            >
            >
            > Stack Trace:
            >
            >
            > [COMException (0x80040220): The "SendUsing" configuration value is
            > invalid.
            > ]
            >
            > [TargetInvocatio nException: Exception has been thrown by the target of
            > an invocation.]
            > System.RuntimeT ype.InvokeDispM ethod(String name, BindingFlags
            > invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
            > Int32 culture, String[] namedParameters ) +0
            > System.RuntimeT ype.InvokeMembe r(String name, BindingFlags
            > invokeAttr, Binder binder, Object target, Object[] args,
            > ParameterModifi er[] modifiers, CultureInfo culture, String[]
            > namedParameters ) +473
            > System.Web.Mail .LateBoundAcces sHelper.CallMet hod(Object obj, String
            > methodName, Object[] args) +58
            >
            > [HttpException (0x80004005): Could not access 'CDO.Message' object.]
            > System.Web.Mail .LateBoundAcces sHelper.CallMet hod(Object obj, String
            > methodName, Object[] args) +113
            > System.Web.Mail .CdoSysHelper.S end(MailMessage message) +1846
            > System.Web.Mail .SmtpMail.Send( MailMessage message) +153
            > CAWAA.E.NeedHel p.btnSubmit_Cli ck(Object sender, EventArgs e) +580
            > System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +108
            >
            > System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
            > eventArgument) +57
            > System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
            > sourceControl, String eventArgument) +18
            > System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
            > +33
            > System.Web.UI.P age.ProcessRequ estMain() +1292
            >
            >
            > Here is the code:
            >
            > Dim objMailMessage As New MailMessage
            > objMailMessage. BodyFormat = MailFormat.Html
            > objMailMessage. From = "blabla@bla .ca"
            > objMailMessage. Subject = "Form Title"
            > objMailMessage. Body = strMessage
            >
            > If Len(strEmailFro m) > 0 Then
            > strEmailTo += ";" & strEmailFrom
            > End If
            >
            > objMailMessage. To = strEmailTo
            > SmtpMail.SmtpSe rver = "127.0.0.1"
            > SmtpMail.Send(o bjMailMessage)
            >
            >
            > This works on our testing server which uses a network service, but it
            > does not work on our production server which does not. Any ideas? I
            > know about the FAQ site System.WEb.Mail , OH MY!, and we have tried all
            > of their suggestions and none of them work.
            >[/color]


            Comment

            Working...