Results 1 to 4 of 4

Thread: E-Mailing Using CDO

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2005
    Posts
    8

    E-Mailing Using CDO

    Hi,

    I'm using the following code in VBA (in Excel) to try to e-mail a number of attachments to a list of recipients :

    VB Code:
    1. Sub Send_Emails()
    2.          
    3.     Sheets("Menu").Select
    4.     Application.ScreenUpdating = False
    5.     Application.StatusBar = "E_Mailing RFQs to Suppliers ..."
    6.     Sheets("DailyRFQs").Select
    7.    
    8.    '    On Error GoTo cleanup
    9.    
    10.     For Each VCODE In Range("VCODE")
    11.        
    12.        
    13.                         Set objCDOMessage = CreateObject("CDO.Message")
    14.                         Set objCDOConfig = CreateObject("CDO.Configuration")
    15.                        
    16.                         With objCDOMessage
    17.                             Set .Configuration = objCDOConfig
    18.                                 .To = VCODE.Offset(0, 2).Value
    19.                                 .Subject = "RFQ: " & VCODE.Offset(0, 12).Value & " - " & VCODE.Value & " " & VCODE.Offset(0, 1).Value
    20.                                 .TextBody = vbNewLine & vbNewLine & _
    21.                                 "Text"
    22.                             .AddAttachment VCODE.Offset(0, 7).Value
    23.                             .AddAttachment VCODE.Offset(0, 8).Value
    24.                             .AddAttachment VCODE.Offset(0, 9).Value
    25.                             .AddAttachment VCODE.Offset(0, 11).Value
    26.                             .Send  'Or use Display
    27.                             .Display
    28. '                            VCODE.Offset(0, 9).Value = "YES"
    29.                         End With
    30.                         Set iMsg = Nothing
    31.                        
    32.     Next
    33.  
    34. cleanup:
    35.     Set objCDOMessage = Nothing
    36.     Set objCDOConfig = Nothing
    37.  
    38.     Application.ScreenUpdating = True
    39.  
    40. End Sub

    On execution I get the following message :

    Run-time error '-2147220960 (80040220)':

    The "SendUsing" configuration value is invalid.

    Does anyone have any suggestions how I can get around this ? I'm tearing me hair out here !!
    Last edited by RobDog888; Oct 18th, 2005 at 02:08 PM. Reason: Added [vbcode] tags

  2. #2
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: E-Mailing Using CDO

    Greg..

    You need to configure the configuration, by setting the server and port options...

    VB Code:
    1. .Configuration.Fields.Item("smtpserver") = "username/outgoingserver"
    2.   .Configuration.Fields.Item("smtpserverport") = 25
    3.   .Configuration.Fields.Item("sendusing") = CdoSendUsingPort
    4.   .Configuration.Fields.Update

    Add this into the With.. End With section and it should work.. you will also need to change the username/outgoingserver to match yours.. If this is exchange then you may not be able to do it..
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2005
    Posts
    8

    Re: E-Mailing Using CDO

    Thanks for that Danny but i haven't got an smtp address as I'm networked unfortunately, so it hasn't worked . . . which is a bugger ! Any idea how I can change the code to send the e-mails using GroupWise as this is what the company uses to send e-mails ?

  4. #4
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: E-Mailing Using CDO

    I have no experience with GroupWise.. but take a look at the configuration in the application to see how it is sending the email from the email account..
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width