Outlook Automation Contact Photo Access

A

Alexander

I am trying to use the office interop to retrieve a contact photo for a
given contact if available

I am able to iterate thru my contacts:

Outlook.ContactItem contact =
(Outlook.ContactItem)contacts.Items;

and i am able to check if a contact has a contact photo:

if(contact.HasPicture)

but i have no idea how i can get access to the ContactPhoto and i been
googling with no luck????
 
A

Alexander

Thanks/Danke Michael,

can you be more specific? i have been trying all day? do i need to use the
OlkContactPhoto object?

please advise




Michael Bauer said:
Look at the Attachments collection.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize eMails:

<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Wed, 10 Oct 2007 18:18:41 -0700 schrieb Alexander:
I am trying to use the office interop to retrieve a contact photo for a
given contact if available

I am able to iterate thru my contacts:

Outlook.ContactItem contact =
(Outlook.ContactItem)contacts.Items;

and i am able to check if a contact has a contact photo:

if(contact.HasPicture)

but i have no idea how i can get access to the ContactPhoto and i been
googling with no luck????
 
M

Michael Bauer [MVP - Outlook]

Sorry, I can't as I never worked with .NET. The MailItem has an Attachments
collections, its childs are Attachment objects. The contact picture is
called 'ContactPicture.jpg'.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize eMails:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Wed, 10 Oct 2007 21:56:01 -0700 schrieb Alexander:
Thanks/Danke Michael,

can you be more specific? i have been trying all day? do i need to use the
OlkContactPhoto object?

please advise




Michael Bauer said:
Look at the Attachments collection.
Am Wed, 10 Oct 2007 18:18:41 -0700 schrieb Alexander:
I am trying to use the office interop to retrieve a contact photo for a
given contact if available

I am able to iterate thru my contacts:

Outlook.ContactItem contact =
(Outlook.ContactItem)contacts.Items;

and i am able to check if a contact has a contact photo:

if(contact.HasPicture)

but i have no idea how i can get access to the ContactPhoto and i been
googling with no luck????
 
A

Alexander

thanks again.... youre right i found it: ContactPictue.jpg

i can now save it like attach.SaveAsFile(@"c:\test.jpg");

is there a way that i can just cast it to say a Bitmap object? i dont think
i can cast the attach as Bitmap as it is a COM object right?




Michael Bauer said:
Sorry, I can't as I never worked with .NET. The MailItem has an
Attachments
collections, its childs are Attachment objects. The contact picture is
called 'ContactPicture.jpg'.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize eMails:

<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Wed, 10 Oct 2007 21:56:01 -0700 schrieb Alexander:
Thanks/Danke Michael,

can you be more specific? i have been trying all day? do i need to use
the
OlkContactPhoto object?

please advise




Michael Bauer said:
Look at the Attachments collection.
Am Wed, 10 Oct 2007 18:18:41 -0700 schrieb Alexander:

I am trying to use the office interop to retrieve a contact photo for a
given contact if available

I am able to iterate thru my contacts:

Outlook.ContactItem contact =
(Outlook.ContactItem)contacts.Items;

and i am able to check if a contact has a contact photo:

if(contact.HasPicture)

but i have no idea how i can get access to the ContactPhoto and i been
googling with no luck????
 
K

Ken Slovak - [MVP - Outlook]

You can't directly cast it, no. You'd have to save it out as a file and read
it back in as a stream or something like that and then use AxHost probably
to convert it to a BMP. However you do it you need a .NET image object that
you can pass to a conversion call.
 
A

Alexander

Thank you - that makes sense but I am having a hard time on Vista with UAC..
Is there any way that I can get my application to gain admin like rights
without any popup confirmation windows?

And i am having problems if outlook is run as a standard user i cannot COM
to it?
 
K

Ken Slovak - [MVP - Outlook]

I have no idea what you mean by "cannot COM to it".

You could see if an application manifest solves the permissions problem but
I tend to doubt it. I think with UAC that if you are taking actions that
require admin permissions that you would have to live with elevation.

I don't see why saving a picture attachment and loading it as a stream would
require elevation though. Are you trying to write it to a protected area
such as Program Files or the installation folder? You should never do that
anyway, all file writing should be done to an unprotected area such as
<LocalAppData>\Temp or some such path.
 

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