Outlook.MailItemClass ObjMailItem = (Outlook.MailItemClass)Application.ActiveInspector().CurrentItem

P

Puneet

Outlook.MailItemClass ObjMailItem = (Outlook.MailItemClass)Application.ActiveInspector().Current Item;

Above line is used to get the reference of outlook email just composed in the new email window of outlook.

But when the this line gets excuted for first time in debug mode than the control goes back to the starting of the function as this is the first line of the function also but when this line gets excuted second time than the excution stopped and the new mail window in which we just composed new email shown.

But it should return the reference of mail just composed .
Is any one here can help me

How to get the refernce of email just composed in the new email window.
 
K

Ken Slovak - [MVP - Outlook]

You should be using MailItem and not MailItemClass in general. If you need a
reference to MailItemClass for something not exposed in MailItem then cast a
new object as MailItemClass from the MailItem object.

In general if you are getting your reference in the NewInspector event
that's a weak object reference and may only contain valid properties for
testing item.Class and a few others. You should wait in general for the
first Inspector.Activate event to do anything else with the item.

I don't understand what you're trying to say in your second paragraph, can
you please explain?
 
P

Puneet

Leave the second paragraph.

My main moto is to get the reference of email just composed in the new email window.

Thats all.

Please suggest me how i can get the reference of the email just composed in the new email window.

I had added the a button in the outlook new email window and i have to get the reference of the email just composed in the function which is called when i click on the custom button added in the toolbar in the new email window .
 
K

Ken Slovak - [MVP - Outlook]

Is your Application object valid and returning a reference to the
Outlook.Application object? If so I would use something like your code but
changed the way I originally mentioned:

Outlook.MailItem ObjMailItem =
(Outlook.MailItem)Application.ActiveInspector().CurrentItem;
 

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