0
votes

At work we are using Outlook 2016 and have recently upgraded to Microsoft Exchange. We have various VBA programs, run from Excel or Access, which create Outlook emails and save them in the Drafts folder, ready to be checked and sent by hand after running the program. These programs used to work before we went over to Microsoft Exchange. Now, when I double-click one of the emails that were saved in Drafts by whichever program I was running, Outlook refuses to send it, and reports the error "The operation failed." No other information or error codes are provided. One of my colleagues has the same problem. Others do not. In theory we should all have the same version of Outlook and Microsoft Exchange. I have discovered that I can reproduce this problem by running code directly within Outlook. I did Alt-F11, enabled macros, inserted a module and pasted the following code into the window.

Sub TestEmail2()

Dim OutMail As Outlook.MailItem
Dim EmailTo As String
Dim EmailSubject As String

EmailTo = "[email protected]"
EmailSubject = "Test Email 2"

Set OutMail = Application.CreateItem(0)

With OutMail
   .To = EmailTo
   .Subject = EmailSubject
   .Save
   .Close 0 ' olSave
End With

Set OutMail = Nothing

Debug.Print "Finished"
End Sub

If I set a breakpoint at "Set OutMail = Nothing", and run the code to that breakpoint (so "Set OutMail = Nothing" hasn't executed yet), then go to my Drafts folder and try to send the email, it will go without errors. If I rerun the code and allow it to run to completion, I get the error if I try to send the email it generates.

I would like to either (1) find a workaround that I can add to the code so I can send messages or (2) find out what is wrong with my Outlook profile so I can ask our IT helpdesk to change it, or change it myself. I don't want our IT helpdesk to reset my profile to the default settings and lose my customisations.

1
I'm confused, you say it refuses to send - but you aren't sending anything with your code. Also, why not use the built in constants to make your code more readable? (olMailItem instead of 0)ProfoundlyOblivious
The idea is that the code does most of the work, creating a number of customised emails. The actual code is much more complicated than this example, which I have reduced to a minimum to show the effect. The user gets full control of whether the emails are sent or not.Zajonc
Please post a code snippet that actually reproduces the problem. One thing to do is remove the Close call - the item is not displayed, so there is nothing to close.Dmitry Streblechenko
That's useful to know. I didn't realise that Close referred to messages that had been displayed. The code that I posted reproduces the problem on my Outlook.Zajonc

1 Answers

0
votes

That usually indicates that the address book is corrupt. Try to use the Resolve or ResolveAll methods to resolve recipients against the address book.

This issue may also occur when a Google Apps Sync for Microsoft Outlook account and a Microsoft Exchange Server account are configured in the same Outlook profile. See "The operation failed" error when you send email messages in Outlook for more information.

Besides, it is also suggested to try repairing Office via Control Panel and see if the issue can be fixed. Also, you may try repairing your PST files.