Event fired while opening a selected mail item in Outlook.

A

ASAR

I am using shared addins in VB.net 2005 for developin Outlook addin. How can
I write my code for changing mailitem body and attachment on the event fired
just before opening a mailitem .
 
K

Ken Slovak - [MVP - Outlook]

The NewInspector event of the Inspectors collection fires when a new item is
opened. However, you cannot rely on the item in the Inspector being fully
populated in that event. If you only want to handle mail items you will need
to check the Inspector.CurrentItem.Class property (using reflection) in that
event and then use the first Inspector.Activate event for that Inspector to
get at the mail item properties such as Body or the Attachments collection.
 
K

Ken Slovak - [MVP - Outlook]

It doesn't matter if the item is new, a reply, a forward or whatever. If you
open it you get a NewInspector event, since all open Outlook items are
displayed in Inspectors.
 
A

ASAR

I tried it it is working but when ichanged the properties of militem like
subject ,body , attachment on this event and save it It doesnot appear while
mail item is opened. I am using following code


Private Sub tyINS_NewInspector(ByVal Inspector As
Microsoft.Office.Interop.Outlook.Inspector) Handles tyINS.NewInspector
Dim test As Object
test = Inspector.CurrentItem
test.Subject = "NEW SUBJECT"
test.Body = "NEW BODY APPENDED TO MAIL ITEM"

test.Save()
End Sub
 
K

Ken Slovak - [MVP - Outlook]

I told you already to use the first Activate() event for that Inspector to
do what you want.
 

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