0

I'm new to fetch MS outlook functionality programmatically (using C#.Net). Here is the things I would like to achieve.

  1. I have list of person's name in an Excel file.
  2. The .Net code should read those names from excel and search their manager's name and designation from the Outlook contact card.
  3. Also, the code should provide the manager's name up to 3rd level manager (that is , Person name -> Manager1 name and designation -> Manager2 name and designation -> Manager3 name and designation).
  4. I would like to extract those and save in an Excel or in a database.

Link : https://support.office.com/en-us/article/use-the-contact-card-aee867d7-fb39-4101-a386-e93008c8c6a1

enter image description here

Is there any way's to achieve this using C#.Net? I see a few code samples in VB (not yet tried), is this only possible in VB.Net? and NOT in C#.Net? How can I achieve this?

halfer
  • 19,824
  • 17
  • 99
  • 186
AskMe
  • 2,495
  • 8
  • 49
  • 102
  • Can this help? https://learn.microsoft.com/en-us/previous-versions/office/office-365-api/api/version-2.0/contacts-rest-operations#using-the-contacts-rest-api – dvitel Aug 27 '19 at 03:07

1 Answers1

0

Call Application.Session.CreateRecipient passing the person's name. Call Recipient.Resolve and read Recipient.AddressEntry.GetExchangeUser().Manager. Be prepared to handle Recipient.Resolve failing and GetExchangeUser() returning null.

If you need to access Manager's manager, recursively call Manager.GetExchangeUser().Manager until you get back null.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78