B
Brian J. Matuschak
Greetings:
I'm working on an Excel automation application used for scheduling
(can't rewrite it now in a better environment). Here's a snippet of
the code I used to generate the AppointmentItem:
strResource = lblFullName.Caption
bytCount = Selection.Columns.Count
bytCol = ActiveCell.Column
' Dates are in top row
strStartDate = Cells(1, bytCol)
strEndDate = Cells(1, bytCol + bytCount - 1)
Set objOutlook = New Outlook.Application
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objMailItem1 = objOutlook.CreateItem(olMailItem)
Set objReqAttendee = objMailItem1.Recipients.Add(strResource)
objReqAttendee.Resolve
If objReqAttendee.Resolved Then
' Create appointment
Set objFolder = objNameSpace.GetSharedDefaultFolder(objReqAttendee,
olFolderCalendar)
If Not objFolder Is Nothing Then
Set objAppItem = objFolder.Items.Add
End If
If Not objAppItem Is Nothing Then
strNote = InputBox("Would you like to add additional
information to the event notice?", _
"Add descriptive text for event")
End If
If strNote "" Then
objAppItem.Body = strNote
End If
With objAppItem
Start = CDate(strStartDate & " 12:00:00 AM")
End = CDate(strEndDate & " 11:00:00 PM")
AllDayEvent = True
Subject = strEventID
BusyStatus = olBusy
Save
End With
Set objMailItem2 = objOutlook.CreateItem(olMailItem)
Set objReqAttendee = objMailItem2.Recipients.Add(strResource)
With objMailItem2
Subject = "Scheduling for " & strEventID
Body = "You have been scheduled for " & strEventID & " for " &
strStartDate & " to " & strEndDate & "." & _
" Please contact the Resource Calendar for details."
Save
Send
End With
Else
MsgBox "The name you selected doesn't match what's in the Outlook
Global Address List." & _
vbCrLf & "Try editing the name to match what is in Outlook."
End If
Set objOutlook = Nothing
Set objNameSpace = Nothing
Set objMailItem1 = Nothing
Set objMailItem2 = Nothing
Set objReqAttendee = Nothing
Set objAppItem = Nothing
------
Given that scheduling is dynamic around here, I've been asked to see if
I can remove an AppointmentItem from someone else's calendar when I use
this technique. Is it possible?
Thanks,
Brian J. Matuschak
(e-mail address removed); (e-mail address removed)
I'm working on an Excel automation application used for scheduling
(can't rewrite it now in a better environment). Here's a snippet of
the code I used to generate the AppointmentItem:
strResource = lblFullName.Caption
bytCount = Selection.Columns.Count
bytCol = ActiveCell.Column
' Dates are in top row
strStartDate = Cells(1, bytCol)
strEndDate = Cells(1, bytCol + bytCount - 1)
Set objOutlook = New Outlook.Application
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objMailItem1 = objOutlook.CreateItem(olMailItem)
Set objReqAttendee = objMailItem1.Recipients.Add(strResource)
objReqAttendee.Resolve
If objReqAttendee.Resolved Then
' Create appointment
Set objFolder = objNameSpace.GetSharedDefaultFolder(objReqAttendee,
olFolderCalendar)
If Not objFolder Is Nothing Then
Set objAppItem = objFolder.Items.Add
End If
If Not objAppItem Is Nothing Then
strNote = InputBox("Would you like to add additional
information to the event notice?", _
"Add descriptive text for event")
End If
If strNote "" Then
objAppItem.Body = strNote
End If
With objAppItem
Start = CDate(strStartDate & " 12:00:00 AM")
End = CDate(strEndDate & " 11:00:00 PM")
AllDayEvent = True
Subject = strEventID
BusyStatus = olBusy
Save
End With
Set objMailItem2 = objOutlook.CreateItem(olMailItem)
Set objReqAttendee = objMailItem2.Recipients.Add(strResource)
With objMailItem2
Subject = "Scheduling for " & strEventID
Body = "You have been scheduled for " & strEventID & " for " &
strStartDate & " to " & strEndDate & "." & _
" Please contact the Resource Calendar for details."
Save
Send
End With
Else
MsgBox "The name you selected doesn't match what's in the Outlook
Global Address List." & _
vbCrLf & "Try editing the name to match what is in Outlook."
End If
Set objOutlook = Nothing
Set objNameSpace = Nothing
Set objMailItem1 = Nothing
Set objMailItem2 = Nothing
Set objReqAttendee = Nothing
Set objAppItem = Nothing
------
Given that scheduling is dynamic around here, I've been asked to see if
I can remove an AppointmentItem from someone else's calendar when I use
this technique. Is it possible?
Thanks,
Brian J. Matuschak
(e-mail address removed); (e-mail address removed)