?
Solved

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

Posted on 2005-03-22
10
Medium Priority
?
1,181 Views
Last Modified: 2010-05-18
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
Comment
Question by:stephengriffin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 13610823
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
 
LVL 1

Author Comment

by:stephengriffin
ID: 13610860
thanks v much! :-)
0
 
LVL 1

Author Comment

by:stephengriffin
ID: 13610866
ive been looking at this myself and using code from exchangecode.com but getting no-where..thanks for your help!
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
LVL 76

Expert Comment

by:David Lee
ID: 13618017
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
 
LVL 1

Author Comment

by:stephengriffin
ID: 13619881
Hi , yes , sorry if i wasnt clear...

want to remove them from the resource calendar...

Cheers!
0
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 total points
ID: 13648978
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
 
LVL 1

Author Comment

by:stephengriffin
ID: 13662970
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
 
LVL 76

Expert Comment

by:David Lee
ID: 13666358
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
 
LVL 1

Author Comment

by:stephengriffin
ID: 13669723
Found the problem :) I had to use "Mailbox - MeetingRoom" instead of "MeetingRoom" ..

Top marks BDF !
0
 
LVL 76

Expert Comment

by:David Lee
ID: 13670306
Excellent. Glad I could help out.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
In this article I discuss my selections of the Top Four free Outlook OST File Viewers available. Open, view and read even damaged OST files by using these tools. They all provide a clear preview of all data such as emails, notes, tasks, calendars, e…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question