View Single Post
  #4  
Old March 19th 10, 08:37 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Automatically modifying an email

The mailto: protocol opens an Outlook item using Simple MAPI.

In Outlook 2002 or later you do get that Inspector added to the Inspectors
collection, but there is no NewInspector() event. There are no events
telling you an item was added. That's true even in Outlook 2010.

The only way I've found to do what you want to do is to use a timer to check
the Inspectors collection against a list of handled Inspectors. I use
Inspector wrappers and wrapper collections anyway, so the infrastructure is
there already for me in any of my addins. If I find an unhandled Inspector I
know it's a Simple MAPI Inspector (which are opened modally, BTW).

Of course there are a number of flags I have to maintain and various
interlocks to make sure I don't handle a normal Outlook Inspector in both
NewInspector() and my timer event handler and end up handling an Inspector
twice. And I double-check on matching Inspectors with more than captions,
for example getting the Inspector window handle and then checking the window
RECT and screen position for a match, among other things. There are a number
of fault use cases where simple matching fails.

A fake To address could work but the item has to be saved to fill that in.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"scottb2" scottb2.48364a@invalid wrote in message
news:scottb2.48364a@invalid...

True, but in the first email, I described a method of getting around the
problem. I'm using mailto to open an email and fill in everything
except for the attachment. I then need to gain control by handling some
event and then using Item.Attachment to create the attachment.

So I have two problems. The first problem is how to let my code know
what is supposed to be attached. By specifying a fake "To" address (as
described in the first email), the code can do the right thing. I then
only need to know how to get control. Would a NewInspector event
handled in the ThisOutlookSession module do the job?

Is the "fake To: address" method workable? Is NewInspector the event
that ThisOutlookSession should be using to get control?

I'm trying to go about it this way because there should be only two
keys hit once the information is selected: the first causes the mailto
command to be constructed and issued and the second submits the email.
I can't have any more keys hit to manually attach a file, manually
select the email, etc.

Scott


Ads