Blog - Title

December, 2008

Brijs Blogging... Looking Beyond the Obvious

  • Brijs Blogging... Looking Beyond the Obvious

    How to set msExchRecipientTypeDetails Active Directory Attribute using VBScript.

    • 1 Comments

    When we move Mailbox from Exchange 2003 to Exchange 2007, it may be shown as Linked Mailbox.

    This issue can occur if the associated external account was set on the user's Microsoft Exchange Server 2003 or Exchange 2000 Server mailbox.

    To resolve the problem, modify the user account attribute msExchRecipientTypeDetails from a value of 2 to a value of 1 using ADSI Edit.

    We can refer to the article mentioned below:

    Or use the sample VBScript given below:

    NOTE: Following programming examples is for illustration only, without warranty either expressed or implied,
    including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose.
    This sample code assumes that you are familiar with the programming language being demonstrated and the tools used
    to create and debug procedures.

       1:  Dim obj
       2:  'ToDo: Modifiy the UserAlias, Domain, DomainExtn
       3:  Set obj = GetObject("LDAP://CN=UserAlias,CN=Users,DC=Domain,DC=DomainExtn")
       4:  obj.msExchRecipientTypeDetails = 1
       5:  obj.SetInfo()
       6:  Set obj = nothing
     
    Hope this helps! Enjoy
  • Brijs Blogging... Looking Beyond the Obvious

    Issue: Unable to set recurrence pattern of an appointment or a meeting as every weekday using Outlook Object Model

    • 2 Comments

    The only available recurrence patterns to set from OOM are as below:

    olRecursDaily = 0,

    olRecursWeekly = 1,

    olRecursMonthly = 2,

    olRecursMonthNth = 3,

    olRecursYearly = 5,

    and olRecursYearNth = 6.

    Though we can set every weekday recurrence pattern using UI, Outlook object model does not expose any method to create the pattern as Every Weekday.

    So, We could use "DayOfWeekMask" to workaround the issue;  We found that the mask value is set to 62 on item when we set the recurrence pattern as Every Weekday through Outlook UI [Daily] -> [Every weekday].

    Here is the sample code snippet in VBA and C# to workaround the issue:

    NOTE: Following programming examples is for illustration only, without warranty either expressed or implied,
    including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose.
    This sample code assumes that you are familiar with the programming language being demonstrated and the tools used
    to create and debug procedures.

    SAMPLE CODE I (VBA):

       1:  Sub CreateTestAppointment()
       2:      Dim myOlApp As Outlook.Application
       3:      Dim myItem As Outlook.AppointmentItem
       4:      Dim myPattern As Outlook.RecurrencePattern
       5:      Set myOlApp = CreateObject("Outlook.Application")
       6:      Set myItem = myOlApp.CreateItem(olAppointmentItem)
       7:      Set myPattern = myItem.GetRecurrencePattern
       8:      myPattern.RecurrenceType = 1
       9:      myPattern.DayOfWeekMask = 62 
      10:      myPattern.StartTime = "12:00 pm" 'Time each appointment begins
      11:      myPattern.EndTime = "1:00 pm" 'Time each appointment ends
      12:      myPattern.PatternStartDate = #7/1/2009# 'Earliest date appt can  Occur
      13:      myPattern.PatternEndDate = #9/2/2009# 'Latest date appt can occur
      14:   
      15:      myItem.Subject = "TestAppointment"
      16:      myItem.Save
      17:      myItem.Display
      18:  End Sub

     

    SAMPLE CODE II (C#):

       1:          try
       2:              {
       3:                  Outlook.Application oApp =(Outlook.Application) new Outlook.Application();
       4:                  Outlook.AppointmentItem newAppointment =(Outlook.AppointmentItem) oApp.CreateItem(Outlook.OlItemType.olAppointmentItem);
       5:                  Outlook.RecurrencePattern oRecurr = newAppointment.GetRecurrencePattern() ;
       6:                  
       7:                  oRecurr.RecurrenceType = Outlook.OlRecurrenceType.olRecursWeekly;
       8:                  oRecurr.DayOfWeekMask = (Outlook.OlDaysOfWeek)62;
       9:                  oRecurr.StartTime = DateTime.Now.AddHours(2);
      10:                  oRecurr.EndTime = DateTime.Now.AddHours(3);
      11:                  oRecurr.PatternStartDate = DateTime.Now.Date;
      12:                  oRecurr.PatternEndDate = DateTime.Now.Date.AddDays(3);
      13:                  
      14:                  newAppointment.Body = "Test Appointment";
      15:                  newAppointment.AllDayEvent = false;
      16:                  newAppointment.Subject = "Test Appointment";
      17:                  newAppointment.Save();
      18:                  newAppointment.Display(true);
      19:              }
      20:              catch (Exception ex)
      21:              {
      22:                  MessageBox.Show("The following error occurred: " + ex.Message);
      23:              }

    References:

    Hope this helps.

Page 1 of 1 (2 items)