A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Deleting Appointment Automatically When Expired



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 9th 09, 09:03 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Deleting Appointment Automatically When Expired

Very slightly modified from an example from the Outlook VBA Help on
Items.Restrict. Always use the Object Browser to look for examples and
sample code:

Public Sub ApptDateCheck()
Dim myNamespace As Outlook.NameSpace
Dim myAppts As Outlook.Items
Dim myItems As Outlook.Items
Dim myItem As Object
Dim i As Long
Dim DateStart As Date

DateStart = Date
Set myNamespace = Application.GetNamespace("MAPI")
Set myAppts = myNamespace.GetDefaultFolder(olFolderCalendar).Ite ms
Set myItems = myAppts.Restrict("[End] """ & DateStart & """")
For i = myItems.Count To 1 Step -1
Set myItem = myItems.Item(i)
If (myItem.Class = olAppointment) Then
myItem.Delete
End If
Next
End Sub

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Orion Cochrane" wrote in message
...
Can you give me the code to do that?
--
I am running on Office 2003, unless otherwise stated.


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook Automatically Deleting Emails Steve Perrins Outlook - General Queries 5 May 22nd 09 09:52 AM
When i open an existing appointment in Outlook Calendar, then close, it automatically creates an unwanted recurring appointment. David H Outlook - Calandaring 1 June 28th 07 10:32 AM
Outlook deleting comments automatically Russ G Outlook - Installation 0 February 9th 07 10:01 PM
Junk e-mail not deleting automatically Penny Miller Outlook - General Queries 2 November 20th 06 04:47 PM
Outlook Automatically Deleting Messages? [email protected] Outlook - General Queries 1 January 31st 06 07:21 PM


All times are GMT +1. The time now is 03:38 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.