How can I get an image of a contact avatar with appearance?

I am trying to get a contact avatar image.

using Microsoft.Office.Interop.Outlook; public sealed class OutlookAvatarFetcher { private static void FetchAvatars() { var outlook = new Application(); var folder = outlook.GetNamespace("MAPI").GetDefaultFolder(OlDefaultFolders.olFolderContacts); var items = folder.Items; for (var i = 0; i < items.Count; ++i) { var contact = items[i + 1] as ContactItem; if (contact == null) continue; if (contact.HasPicture) { // TODO store the picture somehow. } } } } 

But, unfortunately, I can not find an accessory for images.

+4
source share
2 answers

You can use the attachments property for ContactItem :

 contact.Attachments["ContactPicture.jpg"] 

If you want to save the file to disk, for example, you can do something like this:

 contact.Attachments["ContactPicture.jpg"].SaveAsFile(@"{some_path}\ContactPicture.jpg") 
+4
source

Do you mean an image that comes from Facebook or LinkedIn?

You cannot access it - MS did not provide any API for this for legal purposes. Remember that the data comes from a third-party service, and in such cases quite a lot of lawyers are involved.

0
source

Source: https://habr.com/ru/post/1478980/


All Articles