none
Script to Add/Delete Outlook Calendar Entries

    Question

  • Hi,

    Hope someone can help me with this one.

    I got an example script from the internet that I had modified below.

    I modified the script to simply add outlook calendar entries in outlook calendar for 25th/26th December 2010 as "Christmas Day" and "Boxing Day".
    This script is working and I will add more dates to this script later.

    But would some please kindly help modify this script so that it will search and find these 2 calendar entries from outlook calendar and delete them?

    I want to apply the script at user login. 
    The reason I need this is just in case some of my users have corrupted roaming profile and the script will apply twice! Hence, why I need a script to remove the duplicates!

    I've heard you have to use objEvents.Delete and use the MAPIFolder.Items.Find or Restrict method to locate the item(s), then delete them but I dont know how to do this. Any help is much appreciated!

    ---------------------------------------------------------------------------------------------------------

    Const olFolderCalendar = 9
    Const olAppointmentItem = 1
    Const olOutOfOffice = 3

    Set objOutlook = CreateObject("Outlook.Application")
    Set objNamespace = objOutlook.GetNamespace("MAPI")
    Set objCalendar = objNamespace.GetDefaultFolder(olFolderCalendar) 

    Set objDictionary = CreateObject("Scripting.Dictionary")

    objDictionary.Add "December 25, 2010", "Christmas Day"
    objDictionary.Add "December 26, 2010", "Boxing Day" 


    colKeys = objDictionary.Keys

    For Each strKey in colKeys
    dtmHolidayDate = strKey
    strHolidayName = objDictionary.Item(strKey)

    Set objHoliday = objOutlook.CreateItem(olAppointmentItem) 
    objHoliday.Subject = strHolidayName
    objHoliday.Start = dtmHolidayDate & " 9:00 AM"
    objHoliday.End = dtmHolidayDate & " 10:00 AM"
    objHoliday.AllDayEvent = True
    objHoliday.ReminderSet = False
    objHoliday.BusyStatus = olOutOfOffice
    objHoliday.Save
    Next

    --------------------------------------------------------------------
    Any help much appreciated.
    Many thanks! 
    Wednesday, January 12, 2011 8:29 PM

Answers

  • first search for th item may be by subject and then once you have narrowed down to the item you are looking for use the delete method.

    http://msdn.microsoft.com/en-us/library/aa220085(v=office.11).aspx

    above link talks about a folder, buy you have to modify it for ur needs


    Thiyagu | MCTS/MCITP - Exchange 2007 | MCSE 2003[Messaging] | http://www.myExchangeWorld.com. This posting is provided "AS IS" with no warranties, and confers no rights.
    Thursday, January 27, 2011 9:17 AM
    Moderator

All replies

  • Can anyone help me with this please? I've spent 2 hours already researching but no success. Would appreciate any help indeed!
    Wednesday, January 12, 2011 9:29 PM
  • first search for th item may be by subject and then once you have narrowed down to the item you are looking for use the delete method.

    http://msdn.microsoft.com/en-us/library/aa220085(v=office.11).aspx

    above link talks about a folder, buy you have to modify it for ur needs


    Thiyagu | MCTS/MCITP - Exchange 2007 | MCSE 2003[Messaging] | http://www.myExchangeWorld.com. This posting is provided "AS IS" with no warranties, and confers no rights.
    Thursday, January 27, 2011 9:17 AM
    Moderator