Outlook Automation Contact Photo Access

  • Thread starter Thread starter Alexander
  • Start date Start date
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????
 
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????
 
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????
 
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????
 
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.
 
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?
 
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.
 
Back
Top