示例#1
0
        static void Main(string[] args)
        {
            Options options = new Options();
            if (CommandLine.Parser.Default.ParseArguments(args, options))
            {
                MainAsync(options).Wait();
            }

            // Keep the window open when running in debugger
            if (System.Diagnostics.Debugger.IsAttached)
            {
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey();
            }
        }
示例#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)
                });
            }
        }