Search code examples
excelvbawindows-8outlooksurface

Email from excel not working in window 8 2013 issue


Im using the following code and its been working fine. i have updated to a surface pro and know my macro have stop working.

i think it has some think to do will this line in Set OutApp = CreateObject("Outlook.Application")

With window 8 i don't think it uses outlook anymore

Has any one else had this problem

Full code below

Private Sub CommandButton21_Click()
 Dim OutApp As Object
    Dim OutMail As Object

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
        .to = "[email protected]"
        .CC = ""
        .BCC = ""
        .Subject = "Inspection"
        .Body = "Inspection n"
        .Attachments.Add ActiveWorkbook.FullName
        .Send
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub

Solution

  • What Outlook version do you have installed on the PC? Did you check out the Trust Center settings in Outlook?

    In general, your code is correct, I don't see anything strange... The How to automate Outlook from another program article describes the required steps for automating Outlook.

    Be aware, the Click2Run edition of Office 2010 doesn't support automation. Also you may find the You receive run-time error 429 when you automate Office applications article helpful.