Solved

How to delete Outlook 2002 appointments in Visual Basic

Posted on 2003-11-16
5
352 Views
Last Modified: 2013-11-25
Hi There,

I am trying to delete a bunch of Outlook appointments (depending on the dat range) in an Outlook public folder using Visual Basic 6.0.

Could you show me a way to cancel/delete one appointment and also a bunch of appointments in the public folder?


This will definitely help me a lot.


Thank you.
0
Comment
Question by:zetabeta3
5 Comments
 
LVL 1

Expert Comment

by:eScapePro
ID: 9763207


With VB6, first make a reference to the Microsoft Outloook Object model 10.0  (for 2002, 9 for 2000 etc).

To delete an Item, you first need to get a list of items for that folder. You've mentioned you are in a public folder, which means you are going to need to search through the set of folders in your mailbox, otherwise you can use Outlooks GetDefaultFolder method to get an instant reference to the calendar, contacts, inbox etc.


This code will delete all the appointments, if you un-remark the itm.delete line below:

Private Sub CommandButton1_Click()
    Dim olApp       As Outlook.Application
    Dim olNms       As Outlook.NameSpace
    Dim fldCalendar As MAPIFolder
    Dim itmAppt     As AppointmentItem
   
    Set olApp = New Outlook.Application
    Set olNms = olApp.GetNamespace("MAPI")
   
    ' hitting cancel results in a error (i think)
    On Error Resume Next
    Set fldCalendar = olNms.PickFolder
    On Error GoTo Error_Handler
   
    ' Check if user selected cancel or did pick
    ' a folder
    If fldCalendar.Items Is Nothing Then Exit Sub
   
    ' This loops through each Appoitment Item
    ' in the list
    For Each itmAppt In fldCalendar.Items
        '...todo: insert code here

        Debug.Print itmAppt.Subject
        'itmappt.Delete
    Next
   
    Set olApp = Nothing
    Set olNms = Nothing
    Exit Sub
Error_Handler:
End Sub

0
 

Author Comment

by:zetabeta3
ID: 9765676
Hi eScapePro,

Thank you for responding.

I am new to Visual Basic, therefore, I am not familiar with all of the objects and items available in VB.

I have Calendar item called "ProjectTest" in the Public Folders folder.

How do I reference the items in that folder only?

Also instead of looping through each item, is there way for me to delete all of the appintments within a certain date range?

For example, in SQL Server, I would use this query to delete all future appointments:

DELETE from AppointmentTable
WHERE StartTime > GetDate()


Is there something in VB that I do use to delete a bunch of appointments with out looping?



Thank you very much
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 10548538
zetabeta3, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Refund points and save as a 0-pt PAQ.
    *** good comment by from eScapePro, but without followup, is not full answer

Dan Rollins -- EE database cleanup volunteer
0
 

Accepted Solution

by:
CetusMOD earned 0 total points
ID: 10598736
PAQed, with points refunded (125)

CetusMOD
Community Support Moderator
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
Best way to parse out a json string in VB6? 10 218
Trouble with References... 5 59
vbModal 12 57
pop out of webbrowser1 control vba6 5 25
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

808 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