1

The following code snippet works in Windows 10 / Outlook 2013.

In Windows 10 / Outlook 2016 I get an error at the .send line:

Run-time error -2147219712 (80040600):` The operation failed.

The messaging interfaces have returned an unknown error. If the problem persists, restart Outlook. Cannot resolve recipient.

Option Explicit
Sub email_test()
Dim objOutlookApp               As Outlook.Application
Dim objOriginalItem             As Outlook.MailItem
Dim objNewItem                  As Outlook.MailItem
Dim objInspector                As Outlook.Inspector
Dim objRecipient                As Outlook.Recipient
Dim strEmailAddress             As String
Dim strSubject                  As String

Set objOutlookApp = GetObject(, "Outlook.Application")
Set objInspector = objOutlookApp.ActiveInspector
'Set objOriginalItem so that it can be referenced
Set objOriginalItem = objInspector.CurrentItem
'Set objNewItem to create the new message.
Set objNewItem = objOutlookApp.CreateItem(0)
'Store the original body into the new item body
'Note:  objNewItemBody was altered by code not shown here
objNewItem.Body = objOriginalItem.Body
'Note: strEmailAddress was altered by code not shown here
strEmailAddress = "unique_ name@hotmail.com"
Set objRecipient = objOutlookApp.Session.CreateRecipient(strEmailAddress)
objRecipient.Resolve
MsgBox ("The objrecipient.resolved status is: " & objRecipient.Resolved)
'Set the fields of the MailItem.  Note:  objNewItem.Body was previously set
With objNewItem
    .Display
    .Subject = objOriginalItem.Subject
    .To = objRecipient
        'Loop through the attachments in objOriginalItem
        'Save them to the user's temp folder.
        'Attach them to objNewItem.
    .Send
End With

EXUNT:
Set objOutlookApp = Nothing
Set objOriginalItem = Nothing
Set objNewItem = Nothing
Set objInspector = Nothing

End Sub

In Outlook 2016 the MsgBox indicates "True", The User Interface has a window open for the new mail object and the properly-formatted Email address is there.

When I click on the "To" field and then click "Send", the Email is sent.

Outlook 2013 yields a MsgBox indicating "False", but it sends the eMail with user intervention anyway.

How do I resolve this in Outlook 2016 to send the Email without user intervention?

Community
  • 1
  • 1
user3138025
  • 795
  • 4
  • 17
  • 46

2 Answers2

1

0x80040600 is MAPI_E_CORRUPT_STORE. In case of a PST store, that most likely means the PST file is corrupted - try to run scanpst.exe against it. In case of a cached Exchange store, try to delete the OST file and restart Outlook - it will rebuild the OST file.

MAPI error codes can be looked up in OutlookSpy (I am its author) - click "Error Code Lookup" on the OutlookSpy ribbon.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • Hi Dmitry Streblechenko. Thanks for looking at this. I had no PST (No Personal Folders). I have four eMail accounts on this Office 2016 device, and ran SCANPST on all four files a few times. I ran the Outlook VBA again and got the same message. I'm not sure if it matters, but the Outlook 2013 is 32 bit and the Outlook 2016 is 64 bit. – user3138025 Apr 02 '19 at 22:27
  • Hi Dmitry. I thought everything was fine because SCANPST found a few problems with the OST files and fixed them. I have 4 OST files and one of them indicated something like "Only minor discrepancies remain". There was no option to "repair" that OST file when I ran SCANPST again. Anyway, I renamed all the OST files and let Outlook recreate them. The macro runs fine. Thanks for the suggestion. I assume that the "repair" feature of SCANPST isn't all that thorough. Thanks again. – user3138025 Apr 04 '19 at 13:22
  • Scanpst.exe can be used against OST files, but only if rebuilding them is not an option (e.g. a very large mailbox and offline / slow connection). Recreating OST files is the preferred solution. – Dmitry Streblechenko Apr 04 '19 at 14:31
0

0x80040600 is MAPI_E_CORRUPT_STORE. In case of a PST store, that most likely means the PST file is corrupted - try to run scanpst.exe. In case of a cached Exchange store, try to delete the OST file and restart Outlook - it will rebuild the OST file.

MAPI error codes can be looked up in OutlookSpy (I am its author - click "Error Code Lookup" on the OutlookSpy ribbon).

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78