Outlook mail errors out Server Execution Failed

ChuckDrago

Active Member
Joined
Sep 7, 2007
Messages
470
Office Version
  1. 2010
Platform
  1. Windows
One of our field guys is unable to send it automated expenses via a macro controlled Excel Worksheet. His colleagues do without a hitch. IT has not been able to diagnose the problem.
The person is running a W10 laptop, using MS Office 2010. The code is shown below (the error is caused by the line Set OutApp = CreateObject("Outlook.Application.14"))
VBA Code:
Dim OutApp As Object
    Application.DisplayAlerts = False
    Dim OutMail As Object
    Dim FName As String
    FName = ActiveWorkbook.Name
    ActiveWorkbook.SaveAs ("C:\temp\" & FName)
    Set OutApp = CreateObject("Outlook.Application.14")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)
    With OutMail
        .To = MailTo & ";"
        .CC = CcTo
        .BCC = ""
        .Subject = Subj
        .Body = OutMsg & Chr(13) & Chr(13) & Sender
        .Attachments.Add ActiveWorkbook.FullName
        .Send
    End With
    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
    Application.DisplayAlerts = True
End Sub

Any suggestions will be much appreciated, as usual.
Thanks,
Chuck
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Try change this line

Set OutApp = CreateObject("Outlook.Application.14")

For this: (whitout .14)

Set OutApp = CreateObject("Outlook.Application")
 
Upvote 0
One of our field guys is unable to send it automated expenses via a macro controlled Excel Worksheet. His colleagues do without a hitch. IT has not been able to diagnose the problem.
The person is running a W10 laptop, using MS Office 2010. The code is shown below (the error is caused by the line Set OutApp = CreateObject("Outlook.Application.14"))
VBA Code:
Dim OutApp As Object
    Application.DisplayAlerts = False
    Dim OutMail As Object
    Dim FName As String
    FName = ActiveWorkbook.Name
    ActiveWorkbook.SaveAs ("C:\temp\" & FName)
    Set OutApp = CreateObject("Outlook.Application.14")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)
    With OutMail
        .To = MailTo & ";"
        .CC = CcTo
        .BCC = ""
        .Subject = Subj
        .Body = OutMsg & Chr(13) & Chr(13) & Sender
        .Attachments.Add ActiveWorkbook.FullName
        .Send
    End With
    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
    Application.DisplayAlerts = True
End Sub

Any suggestions will be much appreciated, as usual.
Thanks,
Chuck
 
Upvote 0
Look for their reference file in Windows 10 to confirm what they are using .. C:\Program Files (x86)\Microsoft Office\root\ ????

Set OutApp = CreateObject("Outlook.Application")
Set OutApp= CreateObject("Outlook.Application.16")
 
Upvote 0
Dante, the application failed when the .14 wasn't there. Adding it was one of our attempts to make it work. It has to be something else.
Chuck

QuietRiot: I will check as you suggested and try the .16 extension. I'll get back with results
 
Upvote 0
QuietRiot & Dante:
Checked the faulty machine: it is running Office 10 and the Reference file (and Tool-> References) indicate using version 14.
As I said before, running without a version extension does not resolve the problem and .16 wouldn't make sense.
So I am back at square one.
Any other suggestions will be much appreciated.
Chuck
 
Upvote 0
Try this

VBA Code:
Sub test()
  Application.DisplayAlerts = False
  Dim OutApp As New Outlook.Application
  Dim OutMail As MailItem
  Dim FName As String
  Dim MailTo, CcTo, Subj, OutMsg, Sender
  
  Set OutApp = New Outlook.Application
  FName = ActiveWorkbook.Name
  ActiveWorkbook.SaveAs ("C:\temp\" & FName)
  OutApp.Session.Logon
  Set OutMail = OutApp.CreateItem(0)
  With OutMail
      .To = MailTo & ";"
      .CC = CcTo
      .Bcc = ""
      .Subject = Subj
      .Body = OutMsg & Chr(13) & Chr(13) & Sender
      .Attachments.Add ActiveWorkbook.FullName
      .Display 'Send
  End With
  On Error GoTo 0
  Set OutMail = Nothing
  Set OutApp = Nothing
  Application.DisplayAlerts = True
End Sub

Note:
To use early binding, you first need to set a reference to the Outlook object library. Use the Reference command on the Visual Basic for Applications (VBA) Tools menu to set a reference to Microsoft Outlook xx.x Object Library, where xx.x represents the version of Outlook that you are working with.
1576705075781.png
 
Upvote 0
Thank you Dante. It is promising, but I will have to defer until tomorrow to be able to VPN to the field guy's machine.
Will post results either way, but in the meantime I much appreciate your help.
Chuck
PS The Reference Object Library was 14 and it is checked. I'll not touch it.
 
Upvote 0
Buenos dias Dante,
Your proposed solution threw errors on the Dim statements OutApp and OutMail aas well as on the statement Set OutApp. The error message reads "User-defined type not defined". Please advise?
Thanks a bunch!
Chuck
 
Upvote 0

Forum statistics

Threads
1,215,519
Messages
6,125,297
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top