Consulting

Results 1 to 3 of 3

Thread: Excel VBA - Send Email Error

  1. #1
    VBAX Regular
    Joined
    Nov 2013
    Posts
    23
    Location

    Excel VBA - Send Email Error

    Hi,

    Help needed on fixing the problem on sending email from Excel.
    I try to send email (Hotmail or Gmail) from Excel. I do some google and reference code from google and do some modification to suit my need.
    Below are the code that I use and it was not success with error (picture below)
    I try and error to fix it (like change the Server Port, SSL -true/false,...) but could not solve it.


    Error.jpg

    Dim Hotmail_Prep As CDO.Message
    
    Set Hotmail_Prep = New CDO.Message
        With Hotmail_Prep
            With .Configuration.Fields
                .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
                .Item("http://schemas.microsoft.com/cdo/configuration/smptauthenticate") = 1
                .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.live.com"
                .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
                .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 '25 '465 '587
                .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
                .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "***@hotmail.com"
                .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "ZZZ"
                .Update
            End With
        
            .Subject = "Test Email"
            .From = "***@hotmail.com"
            .To = "yyy@hotmail.com"
            .TextBody = "Good morning!"
        End With
        
        'On Error Resume Next
        Hotmail_Prep.Send
        MsgBox ("Mail has been sent")
        
        Set Hotmail_Prep = Nothing
    Thanks,
    KC

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    VBAX Regular
    Joined
    Nov 2013
    Posts
    23
    Location
    Hi manacubus,

    Thanks for your reply.
    I found the solution to send email with using Gmail account. But it was fail on Hotmail account.

Posting Permissions

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