EWS DaysOfWeek cannot be set to enumerated days.


If your trying to set the DaysOfWeek for a WeeklyRecurrencePatternType and find that you cannot set it with enumerated values using code such as the following, you will find that it does not work.


    WeeklyRecurrencePatternType weeklyPattern = new WeeklyRecurrencePatternType();
    weeklyPattern.Interval = 1;
    weeklyPattern.DaysOfWeek = new DayOfWeekType[] {DayOfWeekType.Monday, DayOfWeekType.Wednesday};



OK, DaysOfWeek is a string and needs to be set as such.  There is a problem with the generated proxies in this area - which seems to be tied to the underlying .net framework.  Below are samples which may work.  



This seems to work:
===================
WindowsApplication2.MyExchangeServer.WeeklyRecurrencePatternType weeklyPattern = new
     WindowsApplication2.MyExchangeServer.WeeklyRecurrencePatternType();
weeklyPattern.Interval = 1;
weeklyPattern.DaysOfWeek = DayOfWeekType.Sunday.ToString();


The following may also work:
============================
WindowsApplication2.MyExchangeServer.WeeklyRecurrencePatternType weeklyPattern = new
    WindowsApplication2.MyExchangeServer.WeeklyRecurrencePatternType();


weeklyPattern.Interval = 1;


char aSeperator;
aSeperator = (char)32;


// Set the pattern...
weeklyPattern.DaysOfWeek = WindowsApplication2.MyExchangeServer.DayOfWeekType.Sunday.ToString() + aSeperator +
        WindowsApplication2.MyExchangeServer.DayOfWeekType.Monday.ToString();


// Read back pattern
string[] WeekDays = weeklyPattern.DaysOfWeek.Split((char)32);
foreach (string aDay in WeekDays)
{
    System.Diagnostics.Debug.WriteLine("Day: " + aDay.ToString() + "\n");
}


 

Comments (1)

  1. I’ve put together a list of articles which cover common questions on Exchange Web Services (EWS). These

Skip to main content