MerekThall
New Member
- Joined
- Sep 27, 2018
- Messages
- 3
Hello.
I am trying to dynamically create an Outlook Meeting based on data entered into an Excel userform. I can pass data from other text and combo boxes to establish the start and end dates, location, etc. I am having an issue passing the textbox value for the recipient. Can anyone help me understand what I am doing wrong? The error I get is "Run-time error '287': Application-defined or object-defined error. The code below is attempting to create an email and a meeting, however my issue is with adding recipients to the meeting. In general, I plan to remove the code for creating an email as it was originally written as a means to test functionality passes the form data to Outlook.
Private Sub cmdToOutlook_Click()
Dim OutlookApp as Outlook.Application
Dim OutlookMail as Outlook.MailItem
Dim OutlookCal as Outlook.OlkDateControl
Set OutlookApp = New Outlook.Application
Set OutlookMail = OutlookApp.CreateItem(olMailItem)
With OutlookMail
.BodyFormat = olFormatHTML
.Display
.HTMLBody = "Write your email here"
.To = txtUserID.Value
.CC = txtMgr.Value & "; " & cbCoach.Value
.Subject = "Test Mail from User Form"
End With
Dim OutlookAppt as Outlook.AppointmentItem
Dim rRequiredAttendee as Outlook.Recipient
Dim address as Variant
address = txtUserID.Value
Set OutlookAppt = OutlookApp.CreateItem(olAppointmentItem)
With OutlookAppt
.MeetingStatus = olMeeting
Set rRequiredAttendee = .Recipients.Add(address) 'The error comes from this line
.Subject = "Training"
.Start = txtStartDate.Value
.End = txtEndDate.Value
.Location = "TBD"
.Display
End With
End Sub
Any help is greatly appreciated.
I am trying to dynamically create an Outlook Meeting based on data entered into an Excel userform. I can pass data from other text and combo boxes to establish the start and end dates, location, etc. I am having an issue passing the textbox value for the recipient. Can anyone help me understand what I am doing wrong? The error I get is "Run-time error '287': Application-defined or object-defined error. The code below is attempting to create an email and a meeting, however my issue is with adding recipients to the meeting. In general, I plan to remove the code for creating an email as it was originally written as a means to test functionality passes the form data to Outlook.
Private Sub cmdToOutlook_Click()
Dim OutlookApp as Outlook.Application
Dim OutlookMail as Outlook.MailItem
Dim OutlookCal as Outlook.OlkDateControl
Set OutlookApp = New Outlook.Application
Set OutlookMail = OutlookApp.CreateItem(olMailItem)
With OutlookMail
.BodyFormat = olFormatHTML
.Display
.HTMLBody = "Write your email here"
.To = txtUserID.Value
.CC = txtMgr.Value & "; " & cbCoach.Value
.Subject = "Test Mail from User Form"
End With
Dim OutlookAppt as Outlook.AppointmentItem
Dim rRequiredAttendee as Outlook.Recipient
Dim address as Variant
address = txtUserID.Value
Set OutlookAppt = OutlookApp.CreateItem(olAppointmentItem)
With OutlookAppt
.MeetingStatus = olMeeting
Set rRequiredAttendee = .Recipients.Add(address) 'The error comes from this line
.Subject = "Training"
.Start = txtStartDate.Value
.End = txtEndDate.Value
.Location = "TBD"
.Display
End With
End Sub
Any help is greatly appreciated.