Error "The operation failed" occurs only when Outlook is closed.

D

Dugutigi

I'm using Visual Basic to create and send a message thru Outlook 2003. It
has worked perfectly for over a year at multiple sites, and works whether or
not the user has Outlook open.

However, I have one site where an error occurs only if Outlook is closed.
If Outlook is open, the message is sent just fine. If Outlook is closed, the
user recieves an error message "The operation failed" upon execution of the
following line:

Set objOutlookMailItem = objOutlook.CreateItem(olMailItem)

This is very perplexing because it is only happening at one of over 100
sites. Any help will be greatly appreciated. Thanks.
 
D

Dmitry Streblechenko

Do you have something loke the following befor you execute that code?

set NS = objOutlook.GetNamespace("MAPI")
NS.Logon

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
D

Dugutigi

No I don't. I have:

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMailItem = objOutlook.CreateItem(olMailItem)
With objOutlookMailItem
Set objOutlookRecip = .Recipients.Add(strAmName)
objOutlookRecip.Type = olTo
etc, etc, etc
End With

I will try your suggestion tomorrow since the problem site is on the east
coast and they have gone home for the day.

I still don't understand why this is happening only at one of over 100 sites
which in theory have identical equipment and configurations. But I'm happy
to have something to try. Thank you kindly.

I will post a reply tomorrow with the results.
 
D

Dugutigi

Problem solved. The code you provided below was indeed the answer. Thank
you very much for the prompt response.

Daniel Pitt
Seattle, WA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top