Hello,
I've got a function set up wherein I take HTML-formatted text that I've created in Access (it's a travel itinerary) and send it via Outlook. As a part of this function, the email is displayed for inspection, then, if sent, it captures that fact (boolean) so that I can acknowledge it in a Sub and put the date it was sent and add notes into the associated record.
This is the end of the Sub that builds the itinerary:
This is the function that sends the eMail and returns whether or not the Itinerary was sent:
It all works very nice. If the email is sent, the record is updated through the form and a note is added. If there's a mistake in the itinerary, I just hit close, decline to Save it on the ensuing dialog box, and nothing else happens. All good. 
Now, I want to do the same thing for an Outlook Calendar Item. I can build the itinerary for the body (non-html), create the Calendar item, etc. but I don't know how to make the "check to see if it was saved to the calendar or cancelled" part work.
I have the following, but when using .Saved (I was guessing here) there's no difference in the outcome if I actually Save the item or Cancel and Discard it--it's FALSE either way. Other than that, it works. It creates the item and either puts it in the calendar (if saved) or doesn't (if cancelled.) I just can't figure out how to record the difference.
I appreciate your help!
I've got a function set up wherein I take HTML-formatted text that I've created in Access (it's a travel itinerary) and send it via Outlook. As a part of this function, the email is displayed for inspection, then, if sent, it captures that fact (boolean) so that I can acknowledge it in a Sub and put the date it was sent and add notes into the associated record.
This is the end of the Sub that builds the itinerary:
Code:
...
'All the stuff to build the itinerary and pull together the items needed for the email
...
bSent = SendAnEmail(sRecipient, sBCC, sEmailSubject, sEmailBody, sOutgoingEmailAcct)
If bSent = False Then GoTo Exiting
Select Case bNew 'This is defined earlier in the Sub and drives what to do if the itinerary is sent.
Case 1
Me.txtItinSent = Date
AddBookingNote Me.txtBookingID, "Itinerary Sent. -" & Now()
ItinCalendar
Case 2
Me.chkInCalendar = False
Me.txtDateConfirmed = Null
Me.txtItinSent = Date
AddBookingNote Me.txtBookingID, "Revised Itinerary Sent. -" & Now()
ItinCalendar
Case 3
AddBookingNote Me.txtBookingID, "Duplicate Itinerary Resent. -" & Now()
Case 4
Me.txtItinSent = Date
AddBookingNote Me.txtBookingID, "Existing Itinerary Resent. -" & Now()
End Select
Exiting:
rs.Close
Set rs = Nothing
This is the function that sends the eMail and returns whether or not the Itinerary was sent:
Code:
Public Function SendAnEmail(sRecipient As String, sBCC As String, sSubject As String, sEmailBody As String, sAccount As String, Optional sAttach As String) As Boolean
Dim appOutlook As Outlook.Application
Dim MailOutlook As Outlook.MailItem
Set appOutlook = CreateObject("Outlook.Application")
Set MailOutlook = appOutlook.CreateItem(olMailItem)
With MailOutlook
.SendUsingAccount = .Session.Accounts.Item(sAccount)
.To = sRecipient
.BCC = sBCC
.Subject = sSubject
.HTMLBody = sEmailBody
If sAttach <> "" Then .Attachments.Add sAttach
.Display True
On Error Resume Next
SendAnEmail = .Sent
If Err = 0 Then
SendAnEmail = False
Else
SendAnEmail = True
End If
End With
Set appOutlook = Nothing
Set MailOutlook = Nothing
End Function

Now, I want to do the same thing for an Outlook Calendar Item. I can build the itinerary for the body (non-html), create the Calendar item, etc. but I don't know how to make the "check to see if it was saved to the calendar or cancelled" part work.
I have the following, but when using .Saved (I was guessing here) there's no difference in the outcome if I actually Save the item or Cancel and Discard it--it's FALSE either way. Other than that, it works. It creates the item and either puts it in the calendar (if saved) or doesn't (if cancelled.) I just can't figure out how to record the difference.
Code:
Public Function CreateCalendarItem(sAcct As String, dtStart As Date, dtEnd As Date, sSubject As String, sLocation As String, sItin As String) As Boolean
Dim appOutlook As Outlook.Application
Dim ApptOutlook As Outlook.AppointmentItem
Set appOutlook = CreateObject("Outlook.Application")
Set ApptOutlook = appOutlook.CreateItem(olAppointmentItem)
With ApptOutlook
.ReminderSet = False
.Start = dtStart
.End = dtEnd
.AllDayEvent = True
.Subject = sSubject
.Location = sLocation
.Body = sItin
.Display True
On Error Resume Next
CreateCalendarItem = .Saved
If Err = 0 Then
CreateCalendarItem = False
Else
CreateCalendarItem = True
End If
End With
End Function
I appreciate your help!