Solved

Delete Outlook Calendar Appointments

Posted on 2016-09-15
2
49 Views
Last Modified: 2016-10-29
I am trying to delete all my Outlook Calendar Appointments within a specific date range. But I don't want to delete any appointments that are set to a recurrence since they could be in the future. I found this code online and it works good except that it will delete the recurrence appointments too. Can anyone help me modify this to NOT include recurrence appointments? My VBA skills are terrible and even worse with Outlook.

Private Function DeleteAppts()
'Declarations
Dim strCurrent As String
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim objItems As Outlook.Items
Dim objItem As Object
Dim strStart As String
Dim strEnd As String
Dim strFilter As String
'put required start and end dates into strStart and strEnd respectively
'if they are constants then just set them before this
'I created textboxes for users to input the dates themselves
 
strStart = "09/15/2016 07:00 AM"
strEnd = "09/15/2016 16:00 PM"
'create a string to use to filter the outlook items
strFilter = "[Start] >= " & Quote(strStart) & " And [Start] < " & Quote(strEnd)
 
'set the outlook objects and specify the items in the calendar using the filter
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.GetDefaultFolder(olFolderCalendar)
Set objItems = objFolder.Items.Restrict(strFilter)
Set objItem = objItems.GetFirst
 
intCount = objItems.Count
For i = intCount To 1 Step -1
    Set objItem = objItems(i)
    objItem.Delete
Next

'clears out outlook objects from memory
Set objApp = Nothing
Set objNS = Nothing
Set objFolder = Nothing
Set objItems = Nothing
Set objItem = Nothing
MsgBox "Items Deleted!"
 
End Function

Function Quote(MyText) As String

    Quote = Chr(34) & MyText & Chr(34)

End Function

Open in new window

0
Comment
Question by:Lawrence Salvucci
2 Comments
 
LVL 2

Accepted Solution

by:
kapsionu earned 500 total points
ID: 41823385
Is this some kind of global issue or just personal need? Make it simple, create list view of calendar items with needed fields, sort it, select needed date range, delete, done. Sometimes overthinking is bad for simple tasks. If this is some kind of global need - I would be careful playing with this script.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

910 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now