Word (Mail Merge to Email) object model question

F

Frank

First Question Ever (Yay!)

I have a need to programmatically (VSTO) capture data from outgoing emails
when produced by a mail merge in Word. I've been over the Word (2003) object
model and I see that the mailmerge.execute will generate those emails, but I
can't find any more detail than that.

I'm curious what the events are that acually generate the mailitems... I
assume at some point Word leverages Outlook's mechanisms to create,send, but
Im not sure if this is inside Word's scope, or maybe inside Outlook's realm
of control.

Anyway, I want to reference the mailitems as they're sent so I can glean the
information I need to. I already have the ability to digest mailitems from
within a plug in in Outlook, I just need to make sure I can do the same thing
from Word's outgoing emails.

Any help would be GREATLY apprecaited, thanks in advance,

Frank
 
F

Frank

Frank said:
First Question Ever (Yay!)

I have a need to programmatically (VSTO) capture data from outgoing emails
when produced by a mail merge in Word. I've been over the Word (2003) object
model and I see that the mailmerge.execute will generate those emails, but I
can't find any more detail than that.

I'm curious what the events are that acually generate the mailitems... I
assume at some point Word leverages Outlook's mechanisms to create,send, but
Im not sure if this is inside Word's scope, or maybe inside Outlook's realm
of control.

Anyway, I want to reference the mailitems as they're sent so I can glean the
information I need to. I already have the ability to digest mailitems from
within a plug in in Outlook, I just need to make sure I can do the same thing
from Word's outgoing emails.

Any help would be GREATLY apprecaited, thanks in advance,

Frank


Im going to respond with what I have discovered on further researching. I
was mistaken when I thought Word, when it sent an email, was actually using
Outlook "within itself" to send an email. Word is able to snag an open
instance of the Outlook app and put it's emails as pending outbound emails in
Outlook. Im pretty sure this is all on the client. Weird that if you dont
have outlook running, word is unable to send an email on it's own. pending
outgoing emails will sit and wait for outlook to be run, and then the emails
will appear in the outbox, and get sent with the next sync.

I guess my question becomes, what events can I latch onto to detect when
items are being added into the outlook outbox ?!

I tried the folder.items itemadd event, in my case that doesn't seem to be
getting invoked when outlook isn't already open. when opening outlook after
generating a few emails in Word, I expected outlook to open and maybe a few
itemadds to occur, but that didn't happen.

I guess Ill get back to looking for something on the word side to detect the
contruction of these outbound emails.

Again, any help will be appreciated. Ill keep looking in the interim.

-F
 
K

Ken Slovak - [MVP - Outlook]

When Word sends an email it uses Simple MAPI, not Outlook at all. If Outlook
happens to be registered as the Simple MAPI handler then Outlook will end up
handling the emails, if not whatever else is registered as the Simple MAPI
handler will take care of them.

From an Outlook point of view an Inspector is added when the Simple MAPI
email is opened, it's displayed modally and does not fire the NewInspector
event. If you can get a handle to the Inspector then you can use the usual
MailItem object model to work with it.

That's about it with Word Simple MAPI emails. Same thing for Excel or any
other app that uses Simple MAPI for mail handling.
 
F

Frank

Ken Slovak - said:
When Word sends an email it uses Simple MAPI, not Outlook at all. If Outlook
happens to be registered as the Simple MAPI handler then Outlook will end up
handling the emails, if not whatever else is registered as the Simple MAPI
handler will take care of them.

From an Outlook point of view an Inspector is added when the Simple MAPI
email is opened, it's displayed modally and does not fire the NewInspector
event. If you can get a handle to the Inspector then you can use the usual
MailItem object model to work with it.

That's about it with Word Simple MAPI emails. Same thing for Excel or any
other app that uses Simple MAPI for mail handling.

Thank you for your input!
I think I understand the concept and will experiment with the Inspector in
Outlook. I guess I'm concerned with the case of Word firing off emails and
Outlook not running on that particular client at processing time. I need to
play around with this more.

Thanks for the clarification on the process!
 
F

Frank

I hate to overreach here with another question.

Is it dumb to think I might be able to identify the (requesting?) source of
a mailitem from within outlook? I'm searching through the properties now...

This way, I'd be able to differentiate emails which might be coming from the
Word Mail Merge activity vs. other emails that might be funnelled through
Outlook via the simple MAPI calls....Id hate to do something weak like
populate some sort of identifier in the registry....

Again, thanks :)
 
K

Ken Slovak - [MVP - Outlook]

No way to do that. It makes no difference to Outlook if Word/Excel/etc.
request a Simple MAPI service or if Windows Explorer's Send To does it. It's
just another Simple MAPI request.

You can't even be sure Outlook will handle it even if installed. Outlook can
be there but something like OE or Windows Mail can be the Simple MAPI
handler.
 
F

Frank

Ken Slovak - said:
No way to do that. It makes no difference to Outlook if Word/Excel/etc.
request a Simple MAPI service or if Windows Explorer's Send To does it. It's
just another Simple MAPI request.

You can't even be sure Outlook will handle it even if installed. Outlook can
be there but something like OE or Windows Mail can be the Simple MAPI
handler.

Thanks again! Time to revise some specs :) :D
 

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