Experts Exchange connects you with the people and services you need so you can get back to work.
Improve company productivity with a Business Account.Sign Up
Public Sub AddCalendarEvent(ByVal datDateToCall As Date, ByVal strSubject As String, ByVal strRetailerName As String, _
ByVal strContactName As String, ByVal strPhoneNumber As String)
Dim objOutlook As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim objAppointment As Outlook.AppointmentItem
'If you start Microsoft Outlook, run a second program that accesses Outlook, and then exit Outlook while
'you still have the second program running on your computer, you may receive an error message that is
'similar to the following: The remote server machine does not exist or is unavailable (error 462)
On Error Resume Next
Set objOutlook = Outlook.Application
If Err.Number = 462 Then
'reinitializes the Outlook object model if above error occurs
Set objOutlook = CreateObject("Outlook.Application")
On Error GoTo err_AddCalendarEvent
Set objNameSpace = objOutlook.GetNamespace("MAPI")
'Set objFolder = GetOutlookCalendarFolder
Set objAppointment = objOutlook.CreateItem(olAppointmentItem)
.ReminderMinutesBeforeStart = 0
.Start = datDateToCall
.End = datDateToCall
.Subject = strSubject & ": " & strRetailerName
.Body = "Please Call..." & vbCrLf & vbCrLf & _
"Retailer: " & strRetailerName & vbCrLf & _
"Contact Name: " & strContactName & vbCrLf & _
"Phone Number: " & strPhoneNumber
On Error Resume Next
Set objAppointment = Nothing
Set objOutlook = Nothing
Set objNameSpace = Nothing
Set objFolder = Nothing
MsgBox Err.Number & " " & Err.Description, vbCritical + vbOKOnly, "Error creating Calendar Event"
Open in new window
Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.