Outlook 2003 Automation - Emails not being sent and going into Inb

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

All,

I've got an application that automates Outlook 2003. Up until recently,
everything was working fine.

Then, all of the sudden, an issue started appearing. Here's the details.

1) When Outlook was not open (running in the background via the
CreateObject("Outlook Application"), the email would not be sent, and would
appear in the Inbox Folder with the message "This message has not been sent"
in a gray bar across the top.

2) With Outlook open (appearing in the task bar), the email would be sent
as it should. No issues would be encountered.

Any and all help would be appreciated!! I'm about at my wits end.
 
Right after creating an instance of the Outlook Application object, call
Namespace.Logon:

set App = CreateObject("Outlook Application")
set NS = App.GetNamespace("MAPI")
NS.Logon

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

Thank you VERY MUCH!!! Your code snippet worked.

Does this "Namespace.Logon" apply to all versions of Outlook, or to just
Outlook 2003 and later?

Also, Did was there an update to Outlook that would start causing this?
 
It works in all versions of Outlook.
I doubt it has anything to do with a particular version, but rather with
whether Outlook was already running by the time your code was executed or
not.
If it was already running, you don't need to call Logon. If you do not call
Logon, Outlook tries to be "smart" and logs in implicitly only when it
absolutely need to. All kinds of funny things can happen in the latter
case...

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