Solved

Script to delete/create outlook appointment

Posted on 2014-09-12
1
357 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
1 Comment
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Issue with Outlook Mail 13 57
Outlook Archiving 8 34
outlook office 365 8 84
exchange out of office 8 40
What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
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 …
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…

867 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

21 Experts available now in Live!

Get 1:1 Help Now