Accessing MailItem object in Outbox prevents it being sent

C

Chris_Orange

I have a C++ COM add-in that changes a toolbar custom button state
depending on the item selected. All works fine except for items in
the Outbox waiting to be sent. The sequence is:

1. Configure Outlook to not automatically send new emails (so they
stay in the Outbox long enough).
2. Create a few test emails and Click Send.
3. Switch to the Outbox folder. Most of the emails appear in
bold-italic with the Sent date/time field populated, as normal.
4. When the selection is changed to one of the emails the Explorer
SelectionChange event is fired.
5. The current selection is obtained via the Selection object exposed
by the Explorer using the Selection.Item method.
6. QueryInterface to transform the returned IDispatch interface to a
useable MailItem object.

(After the last step the MailItem properties would then be examined
(Subject, etc.) and used to determine the custom button state).

The last step causes the message to be marked as not ready for
sending: It is no longer in italic, the Sent date/time shows 'None'
but it is still bold (not read). It is similar to if it had been
opened manually (when it shows 'this message has not been sent')
except it still shows as unread. Pressing Send/Receive leaves the
emails in the Outbox.

Doing everything except the QueryInterface in the last step does not
cause the problem.

Q: Is this the expected behaviour?

What I'm looking for is a way to examine the contents of a message in
the Outbox without stopping it from being sent.

I'm running Outlook 2003 on XP.

Many thanks in advance,
Chris
 
K

Ken Slovak - [MVP - Outlook]

Expected behavior. If you do that with items that have been sent you're
causing problems. I'd probably intercept Application.Item_Send and get the
items before they hit the Outbox.
 
C

Chris_Orange

Ken,

Thanks for the reply, that's what I thought but didn't want to hear!
I already intercept the Send event so I'll do as you suggest and also
avoid touching anything in the Outbox.
 

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