• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1273
  • Last Modified:

Script to go through Outlook and delete cancelled meetings....

Hi  ,

Is there a simple script I can run once/sceduled to run through a meeting room resource mailbox and remove all cancelled meetings...

Have Outlook 2000 and Exchange 2000 Ent

Cheers

Stephen
0
stephengriffin
Asked:
stephengriffin
  • 5
  • 5
1 Solution
 
David LeeCommented:
Hi stephengriffin,

I believe I can put a script together that'll do that.  I'll try and post it within the next 24 hours.

Cheers!
0
 
stephengriffinAuthor Commented:
thanks v much! :-)
0
 
stephengriffinAuthor Commented:
ive been looking at this myself and using code from exchangecode.com but getting no-where..thanks for your help!
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
David LeeCommented:
Looking at this question I realize I should have asked a question.  When you say "remove all cancelled meetings" I assume you mean you want them removed from the resource calendar.  Right?  If not, please explain what you have in mind.
0
 
stephengriffinAuthor Commented:
Hi , yes , sorry if i wasnt clear...

want to remove them from the resource calendar...

Cheers!
0
 
David LeeCommented:
Sorry to be so slow in getting this to you.  This macro will search through a resource calendar and delete all canceled appointment items.  The only way I can see to tell that an appointment is canceled is that the subject line changes to begin with "Canceled:".  So that's what this macro keys on.  It searches through the appointments in the resource calendar and deletes all those that begin with "Canceled:".  Of course this presumes that when the meeting planner canceled the meeting they sent a cancellation notice.  If they didn't, then I don't see a way to determine that the meeting has been canceled.  This macro is intended to run against a single resource calendar.  If you need it to run against multiple calendars, then I can make a modification that'll prompt you for the name of the calendar to run against.

Here's what you'll need to do to use this macro.
1.  Start Outlook
2.  Add the resource mailbox to your profile.  You must have permissions on the resource mailbox for this to work.
3.  Click Tools->Macro->Visual Basic Editor
4.  If not already expanded expand Modules and click on Module1
5.  Copy the macro and paste it into the right-hand pane of the VB Editor
6.  Edit the macro as needed
7.  Click the diskette icon on the toolbar to save the changes
8.  Close the VB Editor
9.  Click Tools->Macro->Security
10.  Set the Security Level to Medium
11.  Close Outlook
12.  Start Outlook
13.  Run the macro


'Macro begins here
Sub RemoveCanceledAppointments()
    Dim olResCalendar As Outlook.MAPIFolder, _
        olApptItem As Outlook.AppointmentItem, _
        intCounter As Integer
    'Change the path to the resource calendar on the next line
    Set olResCalendar = OpenMAPIFolder("\MailboxName\Calendar")
    For intCounter = olResCalendar.Items.Count To 1 Step -1
        Set olApptItem = olResCalendar.Items(intCounter)
        If Left(olApptItem.Subject, 9) = "Canceled:" Then
            olApptItem.Delete
        End If
    Next
    Set olApptItem = Nothing
    Set olResCalendar = Nothing
End Sub

'Credit where credit is due.
'The code below is not mine.  I found it somewhere on the internet but do
'not remember where or who the author is.  The original author(s) deserves all
'the credit for these functions.
Function OpenMAPIFolder(szPath)
    Dim app, ns, flr, szDir, i
    Set flr = Nothing
    Set app = CreateObject("Outlook.Application")
    If Left(szPath, Len("\")) = "\" Then
        szPath = Mid(szPath, Len("\") + 1)
    Else
        Set flr = app.ActiveExplorer.CurrentFolder
    End If
    While szPath <> ""
        i = InStr(szPath, "\")
        If i Then
            szDir = Left(szPath, i - 1)
            szPath = Mid(szPath, i + Len("\"))
        Else
            szDir = szPath
            szPath = ""
        End If
        If IsNothing(flr) Then
            Set ns = app.GetNamespace("MAPI")
            Set flr = ns.Folders(szDir)
        Else
            Set flr = flr.Folders(szDir)
        End If
    Wend
    Set OpenMAPIFolder = flr
End Function

Function IsNothing(Obj)
  If TypeName(Obj) = "Nothing" Then
    IsNothing = True
  Else
    IsNothing = False
  End If
End Function
'Macro ends here
0
 
stephengriffinAuthor Commented:
Hi , sorry i hadnt seen this !
 
I tested and edited the code to show the mailbox i need to use but get the following error when running:

Operation Failed : An object could not be found.

At the line:

Set flr = ns.Folders(szDir)...

szdir value is "MeetingRoom" , the name of the mailbox....


Cheers!

0
 
David LeeCommented:
The error means the path is not right.  The path must begin with a \ and you must have the mailbox in the profile you're using with this macro.
0
 
stephengriffinAuthor Commented:
Found the problem :) I had to use "Mailbox - MeetingRoom" instead of "MeetingRoom" ..

Top marks BDF !
0
 
David LeeCommented:
Excellent. Glad I could help out.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now