Having problem getting CurrentItem

G

Guest

Hello,

I'm trying to add a button that pulls in contact info from the highlighted
contact. If I double click the contact and open it up in it's own window,
the following code works.

Outlook.Application oApp = new Outlook.Application();

Outlook.Inspector inspActive;

inspActive = oApp.ActiveInspector();

This works. However, I need to access the contact that is highlighted when.
Meaning when you first click on a contacts folder, to the right in the
display frame you see all your contacts and click one to highlight it. I
need to gather data from the highlighted contact.

Any ideas?

Thanks.

--
(e-mail address removed).<Remove This Before Emailing>

Network & Software Integration
www.n-sv.com

"Helping put the pieces of your IT puzzle together"
 
M

Michael Bauer

Am Thu, 8 Dec 2005 15:41:02 -0800 schrieb kfrost:

It´s the ActiveExplorer.Selection(1)
 
G

Guest

Hello Michael,

Thank you for your reply. I'm using C# in a VSOT project and you can use
ActiveExplorer.Select(1);

I tried the following:
Outlook.Application oApp = new Outlook.Application;
Outlook.Explorer expActive;
Outlook.ContactItem oContactItem;

expActive = oApp.ActiveExplorer();

oContactItem = (Outlook.ContactItem) expActive.Selection; // This is a
property not a method

Fails with a Com cast error.

I then tried adding an Inspector as follows
Outlook.Inspector inspActive;

inspActive = expActive.Selection.Application.ActiveInspector();

Still no luck.



--
(e-mail address removed).<Remove This Before Emailing>

Network & Software Integration
www.n-sv.com

"Helping put the pieces of your IT puzzle together"
 
G

Guest

Actually instead of Selection(1) the following works in C#

oContactItem = (Outlook.ContactItem)expActive.Selection[1];

--
(e-mail address removed).<Remove This Before Emailing>

Network & Software Integration
www.n-sv.com

"Helping put the pieces of your IT puzzle together"
 
D

Dmitry Streblechenko

Or you can use the Item function : Selection.Item(1). Do check that
Selection.Count is greater than 0 first.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

kfrost said:
Actually instead of Selection(1) the following works in C#

oContactItem = (Outlook.ContactItem)expActive.Selection[1];

--
(e-mail address removed).<Remove This Before Emailing>

Network & Software Integration
www.n-sv.com

"Helping put the pieces of your IT puzzle together"


kfrost said:
Hello,

I'm trying to add a button that pulls in contact info from the
highlighted
contact. If I double click the contact and open it up in it's own
window,
the following code works.

Outlook.Application oApp = new Outlook.Application();

Outlook.Inspector inspActive;

inspActive = oApp.ActiveInspector();

This works. However, I need to access the contact that is highlighted
when.
Meaning when you first click on a contacts folder, to the right in the
display frame you see all your contacts and click one to highlight it. I
need to gather data from the highlighted contact.

Any ideas?

Thanks.

--
(e-mail address removed).<Remove This Before Emailing>

Network & Software Integration
www.n-sv.com

"Helping put the pieces of your IT puzzle together"
 

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