?
Solved

Script to delete/create outlook appointment

Posted on 2014-09-12
1
Medium Priority
?
408 Views
Last Modified: 2014-09-22
Hey

I need a script (vbscript) to delete and create a specific calendar appointment i Outlook 2010.

Thanks in advance.

Mike
0
Comment
Question by:mikeydk
[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
1 Comment
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 40318920
HI,

pls try  (cannot test in VBS not Home) but in VBa it runs

to create

Const olAppointmentItem = 1

Set objOutlook = CreateObject("Outlook.Application")
Set objAppointment = objOutlook.CreateItem(olAppointmentItem)

objAppointment.Start = #4/11/2014 10:00 AM#
objAppointment.Duration = 120
objAppointment.Subject = "My Subject"
objAppointment.Body = "my Body."
objAppointment.Location = "tbd"
objAppointment.ReminderMinutesBeforeStart = 30
objAppointment.ReminderSet = True
 
objAppointment.Save
' to delete

DeleteAppointments "My Subject"


Sub DeleteAppointments(strSubj)
Const olAppointmentItem = 1
Const olFolderCalendar = 9
Const olAppointment = 26
Set objOutlook = CreateObject("Outlook.Application")
Set objAppointment = objOutlook.CreateItem(olAppointmentItem)
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNameSpace.GetDefaultFolder(olFolderCalendar)

 
For Each obj In objFolder.Items
  If obj.Class = olAppointment Then
    Set objAppointment = obj
    If InStr(objAppointment.Subject, strSubj) > 0 Then
      intAnswer = MsgBox("Appointment found:-" & vbCrLf & vbCrLf _
           & "Date/time: " & Format(objAppointment.Start, "dd/mm/yyyy hh:nn") _
           & " (" & objAppointment.Duration & "mins)" & Space(10) & vbCrLf _
           & "Subject: " & objAppointment.Subject & Space(10) & vbCrLf _
           & "Location: " & objAppointment.Location & Space(10) & vbCrLf & vbCrLf _
           & "Delete this appointment?", vbYesNo + vbQuestion + vbDefaultButton2, "Delete Appointment?")
      If intAnswer = vbYes Then objAppointment.Delete
    End If
  End If
Next 

Set objOutlook = Nothing
Set objNameSpace = Nothing
Set objFolder = Nothing
Set obj = Nothing
Set objAppointment = Nothing

Exit Sub

Open in new window

Regards
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
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: …
Suggested Courses

741 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