Exemplo n.º 1
0
        static async Task GetUsersContacts(Outlook.ApiClient client, string userEmail)
        {
            Console.WriteLine();
            Console.WriteLine("Fetching user's contacts...");

            try
            {
                Outlook.ItemCollection <Outlook.Contact> contacts =
                    await client.GetContacts(userEmail);

                Console.WriteLine("Fetched {0} contacts", contacts.Items.Count);
                foreach (Outlook.Contact contact in contacts.Items)
                {
                    PrintValue("Created", contact.CreatedDateTime.ToString());
                    PrintValue("Name", contact.DisplayName);
                    if (null != contact.EmailAddresses && contact.EmailAddresses.Length > 0)
                    {
                        PrintValue("Email", contact.EmailAddresses[0].Address);
                    }
                    if (!string.IsNullOrEmpty(contact.PersonalNotes))
                    {
                        PrintValue("Notes", contact.PersonalNotes);
                    }
                    Console.WriteLine();
                }
            }
            catch (HttpRequestException hex)
            {
                PrintError(new string[]
                {
                    "There was an error making the API call to get the user info.",
                    string.Format("ERROR: {0}", hex.Message)
                });
            }
        }
Exemplo n.º 2
0
        static async Task MainAsync(Options options)
        {
            try
            {
                string accessToken = await GetAppToken(options.CertFile, options.CertPass);

                if (!string.IsNullOrEmpty(accessToken))
                {
                    PrintValue("Access token", accessToken);

                    Outlook.ApiClient client = new Outlook.ApiClient();
                    client.AccessToken = accessToken;

                    await GetUserInfo(client, options.UserEmail);

                    if (options.FetchMail)
                    {
                        // Fetch users's mail
                    }

                    if (options.FetchCalendar)
                    {
                        // Fetch user's calendar
                    }

                    if (options.FetchContacts)
                    {
                        // Fetch user's contacts
                        await GetUsersContacts(client, options.UserEmail);
                    }
                }
            }
            catch (Exception ex)
            {
                PrintError(new string[] {
                    "There was an unhandled exception.",
                    string.Format("MESSAGE: {0}", ex.Message),
                    string.Format("STACK: {0}", ex.StackTrace)
                });
            }
        }
Exemplo n.º 3
0
        static async Task GetUserInfo(Outlook.ApiClient client, string userEmail)
        {
            Console.WriteLine();
            Console.WriteLine("Requesting user information...");

            try
            {
                Outlook.User user = await client.GetUser(userEmail);

                PrintValue("User", user.DisplayName);
                PrintValue("Email Address", user.EmailAddress);
            }
            catch (HttpRequestException hex)
            {
                PrintError(new string[]
                {
                    "There was an error making the API call to get the user info.",
                    string.Format("ERROR: {0}", hex.Message)
                });
            }
        }