Sending Email with CDO Object

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

    Sending Email with CDO Object


    I am trying to send mail using CDO.
    The line below ("objMessage.Se nd") blows with this error:
    -21472200960 "Send Using" configuration is invalid"

    Here is the link where I got this code:

    At this link the Dim for objMessage was not listed, so, not knowing how
    to declare it, I declared it as a straight object.

    Here's the code:
    <begin code>
    Dim objMessage As Object
    Set objMessage = CreateObject("C DO.Message")
    objMessage.Subj ect = "Example CDO Message"
    objMessage.From = "MiscAddress@My Company.com"
    objMessage.To = "FromTheDept@My Domain.com"
    objMessage.Text Body = "Test message sent at " & Format(Date,
    "MMDDYYYY") & "-" & Format(Time, "HHMMSS")
    objMessage.Send
    <end code>

    Under Tools/References" I have "Microsoft CDO for Windows 2000" checked,
    as it references C:\Windows\Syst em32\CDOSys.DLL

    What am I doing wrong here?







    *** Sent via Developersdex http://www.developersdex.com ***
  • lyle fairfield

    #2
    Re: Sending Email with CDO Object

    You left out a bunch of required code, and a bigger bunch of not-
    required code. I suspect this is a minimum:

    ' early binding
    ' requires reference to cdosys.dll

    Dim iCfg As CDO.Configurati on
    Dim iMsg As CDO.Message

    Set iCfg = New CDO.Configurati on
    Set iMsg = New CDO.Message

    With iCfg.Fields
    .Item(cdoSendUs ingMethod) = cdoSendUsingPor t
    .Item(cdoSMTPSe rverPort) = 25
    .Item(cdoSMTPSe rver) = "smtp.domain.tl d" 'eg smtp.yahoo.com
    .Item(cdoSMTPAu thenticate) = cdoBasic
    .Item(cdoSendUs erName) = "username"
    .Item(cdoSendPa ssword) = "password"
    .Item(cdoSendEm ailAddress) = "your name <your email address>"
    .Update
    End With

    With iMsg
    .Configuration = iCfg
    .Subject = "Early Binding"
    .To = "someone@domain .tld"
    .TextBody = "Test"
    .Send
    End With

    Set iMsg = Nothing
    Set iCfg = Nothing

    End Sub


    On May 1, 3:17 pm, RLN <nospam...@devd ex.comwrote:
    I am trying to send mail using CDO.
    The line below ("objMessage.Se nd") blows with this error:
    -21472200960 "Send Using" configuration is invalid"
    >
    Here is the link where I got this code:http://www.paulsadowski.com/WSH/cdo..htm#LoadFromFile
    At this link the Dim for objMessage was not listed, so, not knowing how
    to declare it, I declared it as a straight object.
    >
    Here's the code:
    <begin code>
        Dim objMessage As Object
        Set objMessage = CreateObject("C DO.Message")
        objMessage.Subj ect = "Example CDO Message"
        objMessage.From = "MiscAddr...@My Company.com"
        objMessage.To = "FromTheD...@My Domain.com"
        objMessage.Text Body = "Test message sent at " & Format(Date,
    "MMDDYYYY") & "-" & Format(Time, "HHMMSS")
        objMessage.Send
    <end code>
    >
    Under Tools/References" I have "Microsoft CDO for Windows 2000" checked,
    as it references C:\Windows\Syst em32\CDOSys.DLL
    >
    What am I doing wrong here?
    >
    *** Sent via Developersdexht tp://www.developersd ex.com***

    Comment

    Working...