Creating meeting using vba

G

Guest

I was able to create meeting and send out invitations for them via Access,
but for some reason when the invitee responds it gave me a message saying the
meeting is not on the calendar and that it might've been deleted. On my
calendar it also shows that no one had responded to the meeting. Am I
missing arguments when I set the meeting? Any help would be appreciated. (I
posted this message in Access group with no response).

Here's the code that I use:

Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olfolder = olNS.GetDefaultFolder(olFolderInbox)
Set olApptItem = olfolder.Items.Add("IPM.Appointment")


strBodyText = "This is a test please accept the invitation"

'strSubject = "Review Submission ID " & _
' [SubmissionID] & " Due on " & [Due Date]

With olApptItem
.MeetingStatus = olMeeting
.Recipients.Add ("Smith, John ")
.Subject = strSubject
.Start = [Response Due Date]
.Body = strBodyText
.AllDayEvent = True
.ReminderSet = True
.ReminderMinutesBeforeStart = 10080 '1 day reminder = 1440, 1 week = 10080
.Save
.Send
End With
 
D

Dmitry Streblechenko

You are creating the appointment in the Inbox, not the Calendar.
Replace olFolderInbox with olFolderCalendar.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
G

Guest

Thank you, thank you Dmitry...
One more question please: Now if I need to delete the appointment and make
sure that a cancellation email is sent to the invited people, how can I do
that? I was able to delete the meeting, but it didn't send the meeting
cancellation notice. Here's my code :

Dim olApp As Outlook.Application
Dim olNS As NameSpace
Dim olfolder As MAPIFolder
Dim olApptItems As Outlook.Items
Dim olCurrAppt As Outlook.AppointmentItem
Dim strSearch As String
Dim sngMeetingCount As Single
Dim blMeetingDeleted As Boolean

Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olfolder = olNS.GetDefaultFolder(olFolderCalendar)
Set olApptItems = olNS.GetDefaultFolder _
(olFolderCalendar).Items


strSearch = "Test Meeting Invitation"
MsgBox olApptItems.Find("[Subject] = """ & strSearch & """")

Set olCurrAppt = olApptItems.Find("[Subject] = """ & strSearch & """")
FindAppt:
While TypeName(olCurrAppt) <> "Nothing"
olCurrAppt.Delete
blMeetingDeleted = True
sngMeetingCount = sngMeetingCount + 1
MsgBox olCurrAppt.Body
Set olCurrAppt = olApptItems.FindNext
Wend
If blMeetingDeleted = True Then
MsgBox "All meetings (" & sngMeetingCount & ") related to this request
have been deleted"
Me.Repaint
Else
MsgBox "There are no meeting associated to this request."
End If

Set olApptItems = Nothing
Set olCurrAppt = Nothing
Set olfolder = Nothing
Set olNS = Nothing
Set olApp = Nothing


Dmitry Streblechenko said:
You are creating the appointment in the Inbox, not the Calendar.
Replace olFolderInbox with olFolderCalendar.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

dbornt said:
I was able to create meeting and send out invitations for them via Access,
but for some reason when the invitee responds it gave me a message saying
the
meeting is not on the calendar and that it might've been deleted. On my
calendar it also shows that no one had responded to the meeting. Am I
missing arguments when I set the meeting? Any help would be appreciated.
(I
posted this message in Access group with no response).

Here's the code that I use:

Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olfolder = olNS.GetDefaultFolder(olFolderInbox)
Set olApptItem = olfolder.Items.Add("IPM.Appointment")


strBodyText = "This is a test please accept the invitation"

'strSubject = "Review Submission ID " & _
' [SubmissionID] & " Due on " & [Due Date]

With olApptItem
.MeetingStatus = olMeeting
.Recipients.Add ("Smith, John ")
.Subject = strSubject
.Start = [Response Due Date]
.Body = strBodyText
.AllDayEvent = True
.ReminderSet = True
.ReminderMinutesBeforeStart = 10080 '1 day reminder = 1440, 1 week =
10080
.Save
.Send
End With
 
D

Dmitry Streblechenko

Set MeetingStatus property to olMeetingCanceled (5) and call Send.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

dbornt said:
Thank you, thank you Dmitry...
One more question please: Now if I need to delete the appointment and
make
sure that a cancellation email is sent to the invited people, how can I do
that? I was able to delete the meeting, but it didn't send the meeting
cancellation notice. Here's my code :

Dim olApp As Outlook.Application
Dim olNS As NameSpace
Dim olfolder As MAPIFolder
Dim olApptItems As Outlook.Items
Dim olCurrAppt As Outlook.AppointmentItem
Dim strSearch As String
Dim sngMeetingCount As Single
Dim blMeetingDeleted As Boolean

Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olfolder = olNS.GetDefaultFolder(olFolderCalendar)
Set olApptItems = olNS.GetDefaultFolder _
(olFolderCalendar).Items


strSearch = "Test Meeting Invitation"
MsgBox olApptItems.Find("[Subject] = """ & strSearch & """")

Set olCurrAppt = olApptItems.Find("[Subject] = """ & strSearch & """")
FindAppt:
While TypeName(olCurrAppt) <> "Nothing"
olCurrAppt.Delete
blMeetingDeleted = True
sngMeetingCount = sngMeetingCount + 1
MsgBox olCurrAppt.Body
Set olCurrAppt = olApptItems.FindNext
Wend
If blMeetingDeleted = True Then
MsgBox "All meetings (" & sngMeetingCount & ") related to this request
have been deleted"
Me.Repaint
Else
MsgBox "There are no meeting associated to this request."
End If

Set olApptItems = Nothing
Set olCurrAppt = Nothing
Set olfolder = Nothing
Set olNS = Nothing
Set olApp = Nothing


Dmitry Streblechenko said:
You are creating the appointment in the Inbox, not the Calendar.
Replace olFolderInbox with olFolderCalendar.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

dbornt said:
I was able to create meeting and send out invitations for them via
Access,
but for some reason when the invitee responds it gave me a message
saying
the
meeting is not on the calendar and that it might've been deleted. On
my
calendar it also shows that no one had responded to the meeting. Am I
missing arguments when I set the meeting? Any help would be
appreciated.
(I
posted this message in Access group with no response).

Here's the code that I use:

Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olfolder = olNS.GetDefaultFolder(olFolderInbox)
Set olApptItem = olfolder.Items.Add("IPM.Appointment")


strBodyText = "This is a test please accept the invitation"

'strSubject = "Review Submission ID " & _
' [SubmissionID] & " Due on " & [Due Date]

With olApptItem
.MeetingStatus = olMeeting
.Recipients.Add ("Smith, John ")
.Subject = strSubject
.Start = [Response Due Date]
.Body = strBodyText
.AllDayEvent = True
.ReminderSet = True
.ReminderMinutesBeforeStart = 10080 '1 day reminder = 1440, 1 week =
10080
.Save
.Send
End With
 
G

Guest

I'm sorry, as you can probably tell I am new at this. Thank you for the
reply. I tried setting the meetingstatus to olmeetingcanceled then send it
before deleting the meeting, and all it sent out was an updated meeting
notification, it didn't say the meeting was cancelled. When I do send after
the delete, it says the meeting has been deleted and it still didn't send any
cancellation notice. What am I still doing wrong?

Dmitry Streblechenko said:
Set MeetingStatus property to olMeetingCanceled (5) and call Send.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

dbornt said:
Thank you, thank you Dmitry...
One more question please: Now if I need to delete the appointment and
make
sure that a cancellation email is sent to the invited people, how can I do
that? I was able to delete the meeting, but it didn't send the meeting
cancellation notice. Here's my code :

Dim olApp As Outlook.Application
Dim olNS As NameSpace
Dim olfolder As MAPIFolder
Dim olApptItems As Outlook.Items
Dim olCurrAppt As Outlook.AppointmentItem
Dim strSearch As String
Dim sngMeetingCount As Single
Dim blMeetingDeleted As Boolean

Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olfolder = olNS.GetDefaultFolder(olFolderCalendar)
Set olApptItems = olNS.GetDefaultFolder _
(olFolderCalendar).Items


strSearch = "Test Meeting Invitation"
MsgBox olApptItems.Find("[Subject] = """ & strSearch & """")

Set olCurrAppt = olApptItems.Find("[Subject] = """ & strSearch & """")
FindAppt:
While TypeName(olCurrAppt) <> "Nothing"
olCurrAppt.Delete
blMeetingDeleted = True
sngMeetingCount = sngMeetingCount + 1
MsgBox olCurrAppt.Body
Set olCurrAppt = olApptItems.FindNext
Wend
If blMeetingDeleted = True Then
MsgBox "All meetings (" & sngMeetingCount & ") related to this request
have been deleted"
Me.Repaint
Else
MsgBox "There are no meeting associated to this request."
End If

Set olApptItems = Nothing
Set olCurrAppt = Nothing
Set olfolder = Nothing
Set olNS = Nothing
Set olApp = Nothing


Dmitry Streblechenko said:
You are creating the appointment in the Inbox, not the Calendar.
Replace olFolderInbox with olFolderCalendar.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

I was able to create meeting and send out invitations for them via
Access,
but for some reason when the invitee responds it gave me a message
saying
the
meeting is not on the calendar and that it might've been deleted. On
my
calendar it also shows that no one had responded to the meeting. Am I
missing arguments when I set the meeting? Any help would be
appreciated.
(I
posted this message in Access group with no response).

Here's the code that I use:

Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olfolder = olNS.GetDefaultFolder(olFolderInbox)
Set olApptItem = olfolder.Items.Add("IPM.Appointment")


strBodyText = "This is a test please accept the invitation"

'strSubject = "Review Submission ID " & _
' [SubmissionID] & " Due on " & [Due Date]

With olApptItem
.MeetingStatus = olMeeting
.Recipients.Add ("Smith, John ")
.Subject = strSubject
.Start = [Response Due Date]
.Body = strBodyText
.AllDayEvent = True
.ReminderSet = True
.ReminderMinutesBeforeStart = 10080 '1 day reminder = 1440, 1 week =
10080
.Save
.Send
End With
 
G

Guest

One more thing I forgot to mention, I couldn't put the "(5)" behind the
olmeeting canceled, I received a compile error (expected array). I'm using
Outlook XP by the way.

Dmitry Streblechenko said:
Set MeetingStatus property to olMeetingCanceled (5) and call Send.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

dbornt said:
Thank you, thank you Dmitry...
One more question please: Now if I need to delete the appointment and
make
sure that a cancellation email is sent to the invited people, how can I do
that? I was able to delete the meeting, but it didn't send the meeting
cancellation notice. Here's my code :

Dim olApp As Outlook.Application
Dim olNS As NameSpace
Dim olfolder As MAPIFolder
Dim olApptItems As Outlook.Items
Dim olCurrAppt As Outlook.AppointmentItem
Dim strSearch As String
Dim sngMeetingCount As Single
Dim blMeetingDeleted As Boolean

Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olfolder = olNS.GetDefaultFolder(olFolderCalendar)
Set olApptItems = olNS.GetDefaultFolder _
(olFolderCalendar).Items


strSearch = "Test Meeting Invitation"
MsgBox olApptItems.Find("[Subject] = """ & strSearch & """")

Set olCurrAppt = olApptItems.Find("[Subject] = """ & strSearch & """")
FindAppt:
While TypeName(olCurrAppt) <> "Nothing"
olCurrAppt.Delete
blMeetingDeleted = True
sngMeetingCount = sngMeetingCount + 1
MsgBox olCurrAppt.Body
Set olCurrAppt = olApptItems.FindNext
Wend
If blMeetingDeleted = True Then
MsgBox "All meetings (" & sngMeetingCount & ") related to this request
have been deleted"
Me.Repaint
Else
MsgBox "There are no meeting associated to this request."
End If

Set olApptItems = Nothing
Set olCurrAppt = Nothing
Set olfolder = Nothing
Set olNS = Nothing
Set olApp = Nothing


Dmitry Streblechenko said:
You are creating the appointment in the Inbox, not the Calendar.
Replace olFolderInbox with olFolderCalendar.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

I was able to create meeting and send out invitations for them via
Access,
but for some reason when the invitee responds it gave me a message
saying
the
meeting is not on the calendar and that it might've been deleted. On
my
calendar it also shows that no one had responded to the meeting. Am I
missing arguments when I set the meeting? Any help would be
appreciated.
(I
posted this message in Access group with no response).

Here's the code that I use:

Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olfolder = olNS.GetDefaultFolder(olFolderInbox)
Set olApptItem = olfolder.Items.Add("IPM.Appointment")


strBodyText = "This is a test please accept the invitation"

'strSubject = "Review Submission ID " & _
' [SubmissionID] & " Due on " & [Due Date]

With olApptItem
.MeetingStatus = olMeeting
.Recipients.Add ("Smith, John ")
.Subject = strSubject
.Start = [Response Due Date]
.Body = strBodyText
.AllDayEvent = True
.ReminderSet = True
.ReminderMinutesBeforeStart = 10080 '1 day reminder = 1440, 1 week =
10080
.Save
.Send
End With
 
K

Ken Slovak - [MVP - Outlook]

The "5" is the enumeration value of olMeetingCanceled. Use either the
enumeration member or the numeric constant, not both.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top