Implementing Drag and drop events in outlook

A

Ashish

When drag a mail item and drop to some other folder item_add event is called
b'se an item is added to a folder.

But before item_add What's actual event for drag and drop in outlook?
Item_add event is called for all cases like saving a mail, sending a mail,
moving a mail.
But if i want to call item_add event for special case(drag and drop) then
what i need to do.
 
K

Ken Slovak - [MVP - Outlook]

There are no drag and drop events in the Outlook object model, as a look at
the Object Browser will tell you. You'd have to go down to the Windows
message hook level and hook all such messages using Win32 API calls and a
message hook.
 
A

Ashish

Ok i think item_add event is enough to handle the case. But here there is a
problem.

When a new mail arrives application_newmail event(event number 0xfba7 in
c++) is called.And when move a mail from one folder to another folder then
also application_newmail event is called.
I'm facing the problem if a exchange user has some mails in its inbox and i
create profile for this user and login to user using outlook. Here
application_newmail event will call until it receives all mails in
inbox(outlook looks like hang until all mail receive). Is there any way to
recognize this case? Means can i set a bool which tells me that outlook has
received all mails and ready for any action now? When launch outlook
OnStartupComplete is called and return before outlook receive new mails. Is
there any other function which tells outlook is idle now.

Or can we differentiate in application_newmail event for the cases when new
mail arrive or move a mail from one folder to another.
 
K

Ken Slovak - [MVP - Outlook]

If you are getting NewMail() in cases other than when email is delivered to
the Inbox of the primary mailbox then something is very wrong.

That event only fires in that case, and only then at intervals, allowing you
to miss incoming items.

A better event to use would be either Inbox.Items.ItemAdd() or NewMailEx().
NewMailEx() gives you a delimited list of the EntryID's of items that have
come in since the last time that event fired.

ItemAdd() has a limitation common to most MAPI events where it won't fire at
all if more than 16 items come in at once.
 
A

Ashish

There are 2 newmail events in application. I dont know exact functions in
VB. I'm using c++.

newmail(0xf003) this is call when we create a new mail in outlook
newmailex(0xfba7) this is call when a new mail receives in outlook for
following cases
1. new mail receive in inbox folder
2. we create a new mail and save/send it
3. we move a mail from one folder to another folder

For all cases outlook first calls application_newmailex then Items.ItemAdd
NewMailEx() gives you a delimited list of the EntryID's of items that have
come in since the last time that event fired.

Please explain how EntryID's can help?

The critical case is if a exchange user has some mails already in it and we
create a new profile for this user in outlook and login to outlook then
application_newmailex and Items.ItemAdd will be call for all mails which
come to inbox until outlook restored all old mails.
 
K

Ken Slovak - [MVP - Outlook]

You've lost me completely.

There are both NewMail() and NewMailEx() (for VB, VBA, VB.NET and C#). I
don't do C++ but my guess is that the event with the higher index is
NewMailEx(). However, both events should only fire when new mail is
delivered to the default Inbox in that Outlook profile.

If you are seeing anything else then you're seeing something that I've never
heard of in the Outlook object model and I have no idea what's going on.
Just look at the object model in the Object Browser in the Outlook VBA
project to see what I'm talking about.

NewMailEx() should only fire in case 1, never in your cases 2 & 3.

The list of EntryID's you get from NewMailEx() lets you access each new mail
that came in, which is what I thought we were talking about.
 
A

Ashish

You are correct it's NewMailEx(0xfba7) which is call when a new mail receive
in Inbox folder. Lets forget about NewMail(0xf003) it's not related here and
it's only call when we click on File->New Mail item in outlook.
NewMailEx is called when user receives new mails in its inbox folder. Or if
user already contains some mails and we create its profile in outlook. When
we login to user NewMailEx is call which receive all existing mails(which
are on server) in outlook.

But in my outlook(user profile is created using exchange server) NewMailEx
is also called when after creating a new mail we save it, or we move an
existing mail from one folder to another.
So i still dont know by which action item_add event is called.
I think the only way(as per myknowledge) is to implement drag and drop. You
have already said it should do using windows API. I think i should implement
drag and drop in active inspector. I dont know how to do it. Is there any
link available on net?
 
K

Ken Slovak - [MVP - Outlook]

You'd have to research that yourself, I'm not familiar with any such
examples.

I can see NewMailEx() firing when items are downloaded from the Exchange
server on startup only if the profile is cached. If online the items are
already there in Inbox. I still have no idea why you'd see that event in the
other circumstances you mention.
 

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