static void SetOOF(ExchangeService service) { OofSettings userOOF = new OofSettings(); // Select the OOF status to be a set time period. userOOF.State = OofState.Scheduled; // Select the time period to be OOF userOOF.Duration = new TimeWindow(DateTime.Now.AddDays(4), DateTime.Now.AddDays(5)); // Select the external audience that will receive OOF messages. userOOF.ExternalAudience = OofExternalAudience.All; // Select the OOF reply for your internal audience. userOOF.InternalReply = new OofReply("I'm currently out of office. Please contact my manager for critical issues. Thanks!"); // Select the OOF reply for your external audience. userOOF.ExternalReply = new OofReply("I am currently out of the office but will reply to emails when I return. Thanks!"); // Set the selected values. This method will result in a call to the Exchange Server. service.SetUserOofSettings(UserDataFromConsole.GetUserData().EmailAddress, userOOF); // Retrieve the user status and print to the console Ex15_GetOOF_CS.GetOOF(service); }
static void Main(string[] args) { Console.Title = "EWS Test Console"; Console.ForegroundColor = ConsoleColor.Yellow; Console.WindowHeight = Console.LargestWindowHeight * 9 / 10; Console.WindowWidth = Console.LargestWindowWidth / 2; Console.SetWindowPosition(0, 0); Console.SetBufferSize(200, 3000); // Create an instance of the custom URL redirection validator. UrlValidator validator = new UrlValidator(); // Get the user's email address and password from the console. IUserData userData = UserDataFromConsole.GetUserData(); // Create an ExchangeService object with the user's credentials. ExchangeService myService = new ExchangeService(); myService.Credentials = new NetworkCredential(userData.EmailAddress, userData.Password); Console.WriteLine("Getting EWS URL using custom validator..."); // Call the Autodisocer service with the custom URL validator. myService.AutodiscoverUrl(userData.EmailAddress, validator.ValidateUrl); Console.WriteLine(string.Format(" EWS URL is {0}", myService.Url)); Console.WriteLine("Complete"); Console.WriteLine("\r\n"); Console.WriteLine("Press or select Enter..."); Console.ReadLine(); }
static void Main(string[] args) { Console.Title = "EWS Test Console"; Console.ForegroundColor = ConsoleColor.Yellow; Console.WindowHeight = Console.LargestWindowHeight * 9 / 10; Console.WindowWidth = Console.LargestWindowWidth / 2; Console.SetWindowPosition(0, 0); Console.SetBufferSize(200, 3000); ExchangeService service = Service.ConnectToService(UserDataFromConsole.GetUserData()); Mailbox primaryMailbox = new Mailbox(UserDataFromConsole.UserData.EmailAddress); ICollection <DelegateUser> delegates = GetDelegates(service, primaryMailbox); if (delegates != null) { foreach (DelegateUser user in delegates) { Console.WriteLine(user.ToString()); } } else { Console.WriteLine(string.Format("No delegates for account {0}", UserDataFromConsole.UserData.EmailAddress)); } Console.WriteLine("\r\n"); Console.WriteLine("Press or select Enter..."); Console.ReadLine(); }
public static void GetOOF(ExchangeService service) { // Return the Out Of Office object that contains OOF state for the user whose credendials were supplied at the console. // This method will result in a call to the Exchange Server. OofSettings userOOFSettings = service.GetUserOofSettings(UserDataFromConsole.GetUserData().EmailAddress); // Get the (read-only) audience of email message senders outside a client's organization who will receive automatic Out Of Office replies ("All", "Known", or "None"). OofExternalAudience allowedExternalAudience = userOOFSettings.AllowExternalOof; // Get the duration for a scheduled Out Of Office reply. TimeWindow OOFDuration = userOOFSettings.Duration; // Get the ExternalAudience of email message senders outside a client's organization who will receive automatic Out OF Office replies (All/Known/None). OofExternalAudience externalAudience = userOOFSettings.ExternalAudience; // Get the reply to be sent to email message senders outside a client's organization. OofReply externalReply = userOOFSettings.ExternalReply; // Get the reply to be sent to email message senders inside a client's organization. OofReply internalReply = userOOFSettings.InternalReply; // Get the (Disabled/Enabled/Scheduled) state of the Out Of Office automatic reply feature. OofState userOofState = userOOFSettings.State; // Print user status information to the console Console.WriteLine("Allowed External Audience: {0}", allowedExternalAudience); Console.WriteLine("Out of Office duration: {0}", OOFDuration); Console.WriteLine("External Audience: {0}", externalAudience); Console.WriteLine("External Reply: {0}", externalReply); Console.WriteLine("Internal Reply: {0}", internalReply); Console.WriteLine("User OOF state: {0}", userOofState); }
static void Main(string[] args) { Console.Title = "EWS Test Console"; Console.ForegroundColor = ConsoleColor.Yellow; Console.WindowHeight = Console.LargestWindowHeight * 9 / 10; Console.WindowWidth = Console.LargestWindowWidth / 2; Console.SetWindowPosition(0, 0); Console.SetBufferSize(200, 3000); ExchangeService service = Service.ConnectToService(UserDataFromConsole.GetUserData()); Mailbox primaryMailbox = new Mailbox(UserDataFromConsole.UserData.EmailAddress); // Get a list of delegates from the primary mailbox. ICollection <DelegateUser> delegates = Exchange101.Ex_15_GetDelegates_CS.GetDelegates(service, primaryMailbox); // Get the UserIds of the delegates. List <UserId> delegateIds = new List <UserId>(); foreach (DelegateUser delegateUser in delegates) { delegateIds.Add(delegateUser.UserId); } // Remove the delegates from the primary mailbox. RemoveCalendarEditDelegate(service, primaryMailbox, delegateIds.ToArray()); Console.ReadLine(); Console.WriteLine("\r\n"); Console.WriteLine("Press or select Enter..."); Console.ReadLine(); }
private static void GetUserDataFromGivenMailAndPWD(string emailAddress, string password) { UserData = new UserDataFromConsole(); UserData.EmailAddress = emailAddress; UserData.Password = new SecureString(); foreach (char c in password.ToCharArray()) { UserData.Password.AppendChar(c); } UserData.Password.MakeReadOnly(); }
private static void GetSuggestedMeetingTimes(ExchangeService service) { // Create a list of attendees. List <AttendeeInfo> attendees = new List <AttendeeInfo>(); attendees.Add(new AttendeeInfo() { // Change [email protected] to your email address. SmtpAddress = UserDataFromConsole.GetUserData().EmailAddress, AttendeeType = MeetingAttendeeType.Organizer }); attendees.Add(new AttendeeInfo() { // Change [email protected] to your email address. SmtpAddress = "*****@*****.**", AttendeeType = MeetingAttendeeType.Required }); // Specify suggested meeting time options. AvailabilityOptions meetingOptions = new AvailabilityOptions(); meetingOptions.MeetingDuration = 60; meetingOptions.MaximumNonWorkHoursSuggestionsPerDay = 0; meetingOptions.GoodSuggestionThreshold = 49; meetingOptions.MinimumSuggestionQuality = SuggestionQuality.Good; meetingOptions.DetailedSuggestionsWindow = new TimeWindow(DateTime.Now.AddDays(4), DateTime.Now.AddDays(5)); // Return a set of of suggested meeting times. GetUserAvailabilityResults results = service.GetUserAvailability(attendees, new TimeWindow(DateTime.Now, DateTime.Now.AddDays(2)), AvailabilityData.Suggestions, meetingOptions); // Display available meeting times. Console.WriteLine("Availability for {0} and {1}", attendees[0].SmtpAddress, attendees[1].SmtpAddress); Console.WriteLine(); foreach (Suggestion suggestion in results.Suggestions) { Console.WriteLine(suggestion.Date); Console.WriteLine(); foreach (TimeSuggestion timeSuggestion in suggestion.TimeSuggestions) { Console.WriteLine("Suggested meeting time:" + timeSuggestion.MeetingTime); Console.WriteLine(); } } }
private static void GetUserFreeBusy(ExchangeService service) { // Create a list of attendees List <AttendeeInfo> attendees = new List <AttendeeInfo>(); attendees.Add(new AttendeeInfo() { // Use the email address supplied from the console for the organizer's email address SmtpAddress = UserDataFromConsole.GetUserData().EmailAddress, AttendeeType = MeetingAttendeeType.Organizer }); attendees.Add(new AttendeeInfo() { // Change [email protected] to the email address of your prospective attendee SmtpAddress = "*****@*****.**", AttendeeType = MeetingAttendeeType.Required }); // Specify availability options AvailabilityOptions availabilityOptions = new AvailabilityOptions(); availabilityOptions.MeetingDuration = 30; availabilityOptions.RequestedFreeBusyView = FreeBusyViewType.FreeBusy; // Return a set of of free/busy times GetUserAvailabilityResults freeBusyResults = service.GetUserAvailability(attendees, new TimeWindow(DateTime.Now, DateTime.Now.AddDays(1)), AvailabilityData.FreeBusy, availabilityOptions); // Display available meeting times Console.WriteLine("Availability for {0} and {1}", attendees[0].SmtpAddress, attendees[1].SmtpAddress); Console.WriteLine(); foreach (AttendeeAvailability availability in freeBusyResults.AttendeesAvailability) { Console.WriteLine(availability.Result); Console.WriteLine(); foreach (CalendarEvent calendarItem in availability.CalendarEvents) { Console.WriteLine("Free/busy status: " + calendarItem.FreeBusyStatus); Console.WriteLine("Start time: " + calendarItem.StartTime); Console.WriteLine("End time: " + calendarItem.EndTime); Console.WriteLine(); } } }
static void Main(string[] args) { Console.Title = "EWS Test Console"; Console.ForegroundColor = ConsoleColor.Yellow; Console.WindowHeight = Console.LargestWindowHeight * 9 / 10; Console.WindowWidth = Console.LargestWindowWidth / 2; Console.SetWindowPosition(0, 0); Console.SetBufferSize(200, 3000); ExchangeService service = Service.ConnectToService(UserDataFromConsole.GetUserData()); Mailbox primaryMailbox = new Mailbox(UserDataFromConsole.UserData.EmailAddress); AddCalendarEditDelegate(service, primaryMailbox, "*****@*****.**"); Console.ReadLine(); Console.WriteLine("\r\n"); Console.WriteLine("Press or select Enter..."); Console.ReadLine(); }
static void Main(string[] args) { Console.Title = "EWS Test Console"; Console.ForegroundColor = ConsoleColor.Yellow; Console.WindowHeight = Console.LargestWindowHeight * 9 / 10; Console.WindowWidth = Console.LargestWindowWidth / 2; Console.SetWindowPosition(0, 0); Console.SetBufferSize(200, 3000); // Create an AutodiscoverService object to provide user settings. AutodiscoverService autodiscover = new AutodiscoverService(); // Get the email address and password from the console. IUserData userData = UserDataFromConsole.GetUserData(); // Create credentials for the Autodiscover service. autodiscover.Credentials = new NetworkCredential(userData.EmailAddress, userData.Password); // Create an array that contains all the UserSettingName enumeration values. // Your application should only request the settings that it needs. UserSettingName[] allSettings = (UserSettingName[])Enum.GetValues(typeof(UserSettingName)); // Get all the user setting values for the email address. Console.Write("Doing autodiscover lookup for " + userData.EmailAddress + "..."); GetUserSettingsResponse response = GetUserSettings(autodiscover, userData.EmailAddress, 10, allSettings); Console.WriteLine(" complete."); Console.WriteLine(); // Write the user setting values to the console. foreach (UserSettingName settingKey in response.Settings.Keys) { Console.WriteLine(string.Format("{0}: {1}", settingKey, response.Settings[settingKey])); } Console.WriteLine("\r\n"); Console.WriteLine("Press or select Enter..."); Console.ReadLine(); }
private static void GetUserDataFromConsole() { UserData = new UserDataFromConsole(); Console.Write("Enter email address: "); UserData.EmailAddress = Console.ReadLine(); UserData.Password = new SecureString(); Console.Write("Enter password: "******"*"); } } Console.WriteLine(); UserData.Password.MakeReadOnly(); }
static void Main(string[] args) { Console.Title = "EWS Test Console"; Console.ForegroundColor = ConsoleColor.Yellow; Console.WindowHeight = Console.LargestWindowHeight * 9 / 10; Console.WindowWidth = Console.LargestWindowWidth / 2; Console.SetWindowPosition(0, 0); Console.SetBufferSize(200, 3000); ExchangeService service = Service.ConnectToService(UserDataFromConsole.GetUserData()); Mailbox primaryMailbox = new Mailbox(UserDataFromConsole.UserData.EmailAddress); ICollection <DelegateUser> delegates = Exchange101.Ex_15_GetDelegates_CS.GetDelegates(service, primaryMailbox); if (delegates != null) { foreach (DelegateUser delegateUser in delegates) { if (delegateUser.Permissions.CalendarFolderPermissionLevel == DelegateFolderPermissionLevel.Editor) { delegateUser.Permissions.CalendarFolderPermissionLevel = DelegateFolderPermissionLevel.None; } } service.UpdateDelegates(primaryMailbox, MeetingRequestsDeliveryScope.DelegatesAndMe, delegates); } else { Console.Write(string.Format("No delegates found for address {0}.", UserDataFromConsole.UserData.EmailAddress)); } Console.ReadLine(); Console.WriteLine("\r\n"); Console.WriteLine("Press or select Enter..."); Console.ReadLine(); }
public static ExchangeService ConnectToService(bool traceToFile) { // We use this to get the target Exchange version. UserDataFromConsole data = new UserDataFromConsole(); ExchangeService service = new ExchangeService(data.Version); //service.PreAuthenticate = true; if (traceToFile) { service.TraceListener = new TraceListener(); } else { service.TraceEnabled = true; service.TraceFlags = TraceFlags.All; service.TraceEnablePrettyPrinting = true; } UserDataFromConsole.GetUserDataFromConsoleCredUI(ref service); return(service); }
private static void GetUserDataFromConsole() { userData = new UserDataFromConsole(); //Console.Write("Enter email address: "); //userData.EmailAddress = Console.ReadLine(); userData.EmailAddress = ""; userData.Password = new SecureString(); //Console.Write("Enter password: "******"*"); } } Console.WriteLine(); */ foreach (char c in "".ToCharArray()) { userData.Password.AppendChar(c); } userData.Password.MakeReadOnly(); }