Re: QueryInterface returns E_NOINTERFACE in ItemAdd event handler for Outbox folder



If you are dealing with an MSG file, AFAIK MSGFLAG_UNSENT bit can be
manipulated at any time.
That flag is only settable through Extended MAPI (or Redemption, which,
unlike OOM and CDO 1.21, provides both read and write access).

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

"VladT" <vmtreskov@xxxxxxxxx> wrote in message
news:1154100676.888867.211020@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
PR_CLIENT_SUBMIT_TIME doesn't seem a problem, but MSGFLAG_UNSENT looks
more complicated because you can set PR_MESSAGE_FLAGS just before the
first save operation. After the save MSGFLAG_UNSENT bit is set back. I
saw few your posts explaining how to save the message with cleared
MSGFLAG_UNSENT, but they all use Redemption. I don't have it. Could you
recommend some other way to save the message in Read-Only state?

Thanks,
Vlad

Dmitry Streblechenko wrote:
You can always set the PR_CLIENT_SUBMIT_TIME property and clear the
MSGFLAG_UNSENT bit if you want from the message created on top of an MSG
file.
You can also set all the sender related props using
IMAPOSession::QueryIdnetity and/or IOlkAccountManager

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

"VladT" <vmtreskov@xxxxxxxxx> wrote in message
news:1154029198.788400.162060@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Thanks - PR_SEARCH_KEY sounds interesting solution. The problem is that
it may take few minutes till it'll come to the sent items and user may
need the file earlier. Another thing - there is some third party
application that does almost the same thing that I do in ItemSend
event. The only difference is that they have PR_CLIENT_SUBMIT_TIME
property properly set and MSGFLAG_UNSENT flag is clear. We both are
missing all sender properties but anyway - I need to get closer to
their results. There is still some chance that they fake it by saving
message and setting up those properties but I'm still trying to find
the right approach.

Thanks again,

Vlad


Dmitry Streblechenko wrote:
Again, the biggest problem here is that the mesage will be gone from
the
Outbox while you process the event handler (especially if you display
your
own UI).
A message in the Outbox is the same as the one in the ItemSend event -
it
tis still unsent and the sender props are nott set.
Why don't you display the UI in the ItemSend event, save the user
choices
using MailItem.UserProperties collection, then do the actual
processing
when
the message hits the Sent Items folder, but this time without any UI.
If you don't want to use UserProperties, save the data elsewhere
(registry,
memory, etc) based on the value of PR_SEARCH_KEY property retrieved
from
the
message (can't use the entry id because it changes)

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

"VladT" <vmtreskov@xxxxxxxxx> wrote in message
news:1154025086.421518.25680@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Thanks Dmitry,

Yes, I always have this problem. I can catch this message on
ItemSent
and use the same technique - it'll work fine.
The difference between catching it in Outbox and SentItems is in
timing: the sent message comes to Outbox immediately whereas
SentItems
folder receives it later on - depends on user preferences. It may be
delayed and accumulated in Outbox and force me to deal with many
messages.
When I catch the message I launch a dialog to ask user few questions
(for example - the file name to save the message) and I don't want
to
play with User Properties to save those answers because I want to
leave
the message without my footprints.
So, if there is no difference between catching it in Outbox or in
SentItems - it is just great for me. What about MSGFLAG_UNSENT flag
in
PR_MESSAGE_FLAGS property? Do I have PR_CLIENT_SUBMIT_TIME property
properly set at this time? BTW, when I receive the event, IDispatch
is
not a NULL pointer. And another observation: my Outbox folder gets
highlighted just when I receive ItemChange event (right after
ItemAdd)

Thank you very much for your response again. Hopefully you'll have
some
idea how to solve this issue.


Dmitry Streblechenko wrote:
Do you always have that problem? Or just with some messages?
Firstly,
there
can be items other than MailItem sent (e.g. meeting requests),
secondly,
by
the time your event handler is called, the item is most likely
already
sent
and moved to the Sent Items folder.
What does ItemAdd on the Outbox buy you? It is not any differentt
from
ItemAdd on the Sent Items folder functionality wise, but it is
guaranteed
to
cause problems.

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

<vmtreskov@xxxxxxxxx> wrote in message
news:1154018951.015330.36550@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I'm trying to catch an outgoing message and to save it to file.

I can't use ItemSent or ItemAdd (for SentItems folder) event
handler.
In first case some properties are missing (even if I save
message:
mailItem->Save()) and the second one is too late for my business
logic
(it works fine though - it is just not covering all use cases).
ItemAdd event for Outbox may work better for me but when it comes
to
the handler and I try to retrieve MailItem from IDispatch, the
QueryInterface method returns E_NOINTERFACE.

STDMETHODIMP MyClass::OnItemAddOutbox(IDispatch* item)
{
Outlook::_MailItemPtr mailItem;
HRESULT hr = item->QueryInterface(__uuidof(Outlook::_MailItem),
(void**)&mailItem);
....
}

Any thoughts?

Vlad






.



Relevant Pages


Quantcast