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

Discussion in 'ASP .Net' started by lds, Nov 4, 2005.

  1. lds

    lds Guest

    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.
    ]

    [TargetInvocationException: Exception has been thrown by the target of
    an invocation.]
    System.RuntimeType.InvokeDispMethod(String name, BindingFlags
    invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
    Int32 culture, String[] namedParameters) +0
    System.RuntimeType.InvokeMember(String name, BindingFlags
    invokeAttr, Binder binder, Object target, Object[] args,
    ParameterModifier[] modifiers, CultureInfo culture, String[]
    namedParameters) +473
    System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
    methodName, Object[] args) +58

    [HttpException (0x80004005): Could not access 'CDO.Message' object.]
    System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
    methodName, Object[] args) +113
    System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1846
    System.Web.Mail.SmtpMail.Send(MailMessage message) +153
    CAWAA.E.NeedHelp.btnSubmit_Click(Object sender, EventArgs e) +580
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
    eventArgument) +57
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
    sourceControl, String eventArgument) +18
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
    +33
    System.Web.UI.Page.ProcessRequestMain() +1292


    Here is the code:

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

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

    objMailMessage.To = strEmailTo
    SmtpMail.SmtpServer = "127.0.0.1"
    SmtpMail.Send(objMailMessage)


    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.
    lds, Nov 4, 2005
    #1
    1. Advertising

  2. lds

    sp3d2orbit Guest

    Smtp.SendUsing = 2
    sp3d2orbit, Nov 4, 2005
    #2
    1. Advertising

  3. lds

    lds Guest

    sp3d2orbit wrote:
    > Smtp.SendUsing = 2



    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?
    lds, Nov 4, 2005
    #3
  4. lds

    sp3d2orbit Guest

    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("");
    msg.To.Add("");
    msg.Subject = "test subject";
    msg.Body = "test body";

    SmtpClient smtp = new SmtpClient();
    smtp.Host = "smtp.yourdomain.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_namespace("CDO") rename("EOF", "adoEOF")

    ....

    CDO::IMessagePtr pMail = NULL;
    pMail.CreateInstance(__uuidof(CDO::Message));

    pMail->put_To("");
    pMail->put_From("");
    pMail->put_Subject("test subject");
    pMail->put_TextBody("test body");

    CDO::IConfigurationPtr pConfig(__uuidof(CDO::Configuration));
    FieldsPtr pFields = pConfig->GetFields();
    pFields->Item["http://schemas.microsoft.com/cdo/configuration/smtpserver"]->Value

    =
    _variant_t("smtp.yourdomain.com"); pFields->Item["http://schemas.microsoft.com/cdo/configuration/smtpserverport"]->Value
    = _variant_t((long)25);
    pFields->Item["http://schemas.microsoft.com/cdo/configuration/sendusing"]->Value
    = _variant_t(2);
    pFields->Update();

    pMail->Configuration = pConfig;
    pMail->Send();

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

    Best of luck,
    Matt Furnari
    sp3d2orbit, Nov 4, 2005
    #4
  5. lds

    Greg Burns Guest

    Sure this won't matter, but I use:

    SmtpMail.SmtpServer = "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" <> wrote in message
    news:...
    >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.
    > ]
    >
    > [TargetInvocationException: Exception has been thrown by the target of
    > an invocation.]
    > System.RuntimeType.InvokeDispMethod(String name, BindingFlags
    > invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
    > Int32 culture, String[] namedParameters) +0
    > System.RuntimeType.InvokeMember(String name, BindingFlags
    > invokeAttr, Binder binder, Object target, Object[] args,
    > ParameterModifier[] modifiers, CultureInfo culture, String[]
    > namedParameters) +473
    > System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
    > methodName, Object[] args) +58
    >
    > [HttpException (0x80004005): Could not access 'CDO.Message' object.]
    > System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
    > methodName, Object[] args) +113
    > System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1846
    > System.Web.Mail.SmtpMail.Send(MailMessage message) +153
    > CAWAA.E.NeedHelp.btnSubmit_Click(Object sender, EventArgs e) +580
    > System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
    >
    > System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
    > eventArgument) +57
    > System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
    > sourceControl, String eventArgument) +18
    > System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
    > +33
    > System.Web.UI.Page.ProcessRequestMain() +1292
    >
    >
    > Here is the code:
    >
    > Dim objMailMessage As New MailMessage
    > objMailMessage.BodyFormat = MailFormat.Html
    > objMailMessage.From = ""
    > objMailMessage.Subject = "Form Title"
    > objMailMessage.Body = strMessage
    >
    > If Len(strEmailFrom) > 0 Then
    > strEmailTo += ";" & strEmailFrom
    > End If
    >
    > objMailMessage.To = strEmailTo
    > SmtpMail.SmtpServer = "127.0.0.1"
    > SmtpMail.Send(objMailMessage)
    >
    >
    > 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.
    >
    Greg Burns, Nov 4, 2005
    #5
  6. lds

    sp3d2orbit Guest

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

    MailMessage msg = new MailMessage();
    msg.To = "";
    msg.From = "";
    msg.Subject = "test subject";
    msg.Body = "test body";
    msg.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"]
    = 25;
    msg.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"]
    = "smtp.yourdomain.com";
    msg.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"]
    = 2;
    SmtpMail.SmtpServer = "smtp.yourdomain.com";
    SmtpMail.Send(msg);

    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
    sp3d2orbit, Nov 4, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve
    Replies:
    0
    Views:
    5,320
    Steve
    Jul 1, 2003
  2. =?Utf-8?B?Zm1AbmV3c2dyb3Vwcy5ub3NwYW0=?=

    SendUsing configuration value is invalid

    =?Utf-8?B?Zm1AbmV3c2dyb3Vwcy5ub3NwYW0=?=, Sep 28, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    9,955
    Steven Cheng[MSFT]
    Oct 21, 2004
  3. Elie
    Replies:
    1
    Views:
    792
    Hans Kesting
    Oct 19, 2004
  4. CK
    Replies:
    1
    Views:
    691
    Aaron [SQL Server MVP]
    Oct 28, 2004
  5. Replies:
    0
    Views:
    270
Loading...

Share This Page