GordonPrince
asked on
use VBA to send appointment or meeting request, but I don't want to attend
I've got an Access VBA application that I want to create appointments from. I've used FreeBusy information to figure out when someone's available, now I need to send them an email notifying them that I've booked them. Plus I want to book the room at the same time.
This seems to work with the following VBA code. Except that I'm included in the meeting, and I don't want to be. So how can I do this?
I know how to scroll through a list of Mailboxes, find the right Mailbox, then add the Appointment Item to that folder (instead of my default Appointment folder). But I'd like to have a way of doing this without requiring everyone who uses the application to open every possible recipient's Mailbox.
Since I have 23 possible recipients + 6 meeting rooms, I thought maybe another way to do it would be to send the appointment request on behalf of the meeting room, then add the other person to the recipients list. That would only require having the 6 meeting rooms open from the user's Outlook. But still, I wonder if there's a way to do this without requiring that any of these other Mailboxes are open.
I thought there should be a way to remove me from the Recipients collection, but I'm not in the collection. Probably because it doesn't make logical sense to add something to my calendar, but then have me not attending.
Also, would any of this make any difference using a Meeting item instead of an Appointment item? The definition in the Outlook help I've seen about them is that a Meeting is an Appointment with a second person or a Room or Equipment, etc.
Any thoughts on this greatly appreciated.
This seems to work with the following VBA code. Except that I'm included in the meeting, and I don't want to be. So how can I do this?
I know how to scroll through a list of Mailboxes, find the right Mailbox, then add the Appointment Item to that folder (instead of my default Appointment folder). But I'd like to have a way of doing this without requiring everyone who uses the application to open every possible recipient's Mailbox.
Since I have 23 possible recipients + 6 meeting rooms, I thought maybe another way to do it would be to send the appointment request on behalf of the meeting room, then add the other person to the recipients list. That would only require having the 6 meeting rooms open from the user's Outlook. But still, I wonder if there's a way to do this without requiring that any of these other Mailboxes are open.
I thought there should be a way to remove me from the Recipients collection, but I'm not in the collection. Probably because it doesn't make logical sense to add something to my calendar, but then have me not attending.
Also, would any of this make any difference using a Meeting item instead of an Appointment item? The definition in the Outlook help I've seen about them is that a Meeting is an Appointment with a second person or a Room or Equipment, etc.
Any thoughts on this greatly appreciated.
Dim oApp As Outlook.Application
Dim oAppt As Outlook.AppointmentItem
Dim oRecipts As Outlook.Recipients
Dim oRecipt As Outlook.Recipient
Set oApp = CreateObject("Outlook.Application")
Set oAppt = oApp.CreateItem(olAppointmentItem)
With oAppt
.MeetingStatus = Outlook.OlMeetingStatus.olMeeting
.Subject = "Intake Appointment for " & Me.txtClientName
If Not IsNull(Me.txtRoom) Then .Location = Me.txtRoom
.Start = Me.txtDateTime
.End = DateAdd("n", Me.txtMinutes, .Start)
.ReminderMinutesBeforeStart = 5
.ReminderSet = True
.BusyStatus = Outlook.OlBusyStatus.olBusy
.IsOnlineMeeting = False
.AllDayEvent = False
' Add interviewer
Set oRecipts = oAppt.Recipients
Set oRecipt = oRecipts.Add(Me.txtInterviewer)
oRecipt.Type = Outlook.OlMeetingRecipientType.olRequired
.Display
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This looks promising:
'This Visual Basic for Applications (VBA) example uses the GetSharedDefaultFolder method to resolve the Recipient object representing Dan Wilson, and then returns Dan's shared default Calendar folder.
'This Visual Basic for Applications (VBA) example uses the GetSharedDefaultFolder method to resolve the Recipient object representing Dan Wilson, and then returns Dan's shared default Calendar folder.
Sub ResolveName()
Dim myOlApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myRecipient As Outlook.Recipient
Dim CalendarFolder As Outlook.MAPIFolder
Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myRecipient = myNamespace.CreateRecipient("Dan Wilson")
myRecipient.Resolve
If myRecipient.Resolved Then
Call ShowCalendar(myNamespace, myRecipient)
End If
End Sub
Sub ShowCalendar(myNamespace, myRecipient)
Dim CalendarFolder As Outlook.MAPIFolder
Set CalendarFolder = _
myNamespace.GetSharedDefaultFolder _
(myRecipient, olFolderCalendar)
CalendarFolder.Display
End Sub
ASKER
no experts commented, one of my ideas turned out to be workable
ASKER
http://msdn.microsoft.com/en-us/library/ms875944(v=EXCHG.65).aspx
that describes how to do it using CDO.
But since CDO is not supported in Outlook 2010, does anyone know of a way to do this without using CDO?