Send Outlook appointments (1 Viewer)

pekajo

Registered User.
Local time
Tomorrow, 06:31
Joined
Jul 25, 2011
Messages
132
Hi,
Is there a quick code to send an Outlook meeting request via email.
If you have it or can refer me I would appreciate it.
Regards
Peter
 

vba_php

Forum Troll
Local time
Today, 14:31
Joined
Oct 6, 2019
Messages
2,884
check this answer out:

https://www.access-programmers.co.uk/forums/showpost.php?p=1653386&postcount=11

it is a smaller part of this thread:

https://www.access-programmers.co.uk/forums/showthread.php?t=308115

in which the question asker wanted code to manipulate an email object in outlook. i assume you can do the same for an appointment object in outlook. you can take that code and google the rest to find out how to replace the relevant code with the appointment object's code in outlook. shouldn't be too tough.
 

nhorton79

Registered User.
Local time
Tomorrow, 08:31
Joined
Aug 17, 2015
Messages
147
I might be a little late to the party, but this is what I use...

It handles them as either appointments or meeting requests.

Code:
Dim objOutlook As Object
Dim sAPPPath As String
Dim objMyMsgItem As Object
Dim objMyApptItem As Object

If IsAppRunning("Outlook.Application") = True Then    'Outlook was already running
    Set objOutlook = GetObject(, "Outlook.Application")    'Bind to existing instance of Outlook
Else    'Could not get instance of Outlook, so create a new one
    sAPPPath = GetAppExePath("outlook.exe")    'determine outlook's installation path
    Shell (sAPPPath)    'start outlook
    Do While Not IsAppRunning("Outlook.Application")
        DoEvents
    Loop
    Set objOutlook = GetObject(, "Outlook.Application")    'Bind to existing instance of Outlook
End If


'Create the Message Item and fill the Body text with the formatted text
Set objMyMsgItem = objOutlook.CreateItem(0)

With objMyMsgItem
    .HTMLBody = Nz(Me.txtApptNotes, "")
    .Display
End With

'Create the Appointment Item and populate all the fields except the body text
Set objMyApptItem = objOutlook.CreateItem(1)

'Now use the WordInspector to copy the formatted text from the Message Item to the Appointment Item.
Dim MyMsgInspector As Object
Dim wdDoc_Msg As Object
Set MyMsgInspector = objMyMsgItem.GetInspector
Set wdDoc_Msg = MyMsgInspector.WordEditor

Dim MyApptInspector As Object
Dim wdDoc_Appt As Object
Set MyApptInspector = objMyApptItem.GetInspector
Set wdDoc_Appt = MyApptInspector.WordEditor

wdDoc_Appt.Range.FormattedText = wdDoc_Msg.Range.FormattedText


'Now close the message item and discard
objMyMsgItem.Close (olDiscard)


'Set up the appointment with the correct fields
With objMyApptItem

    .ReminderOverrideDefault = True
    .ReminderSet = True
    .ReminderMinutesBeforeStart = Me.ApptRemindBeforehand

    .Subject = Nz(Me.txtApptSubject, "")
    .Location = Nz(Me.txtApptLocation, "")
    
    .Start = Me.txtApptStart
    .End = Me.txtApptEnd
    .Duration = Me.txtApptDurationMinutes
    .AllDayEvent = Me.chkAllDayEvent

    .Importance = Me.cboApptImportance
    .BusyStatus = Me.cboApptShowTimeAs
    
    .Mileage = Me.txtApptID 'Store the appointment id in the mileage field for later reference, changes etc.
    
    'Now determine whether to save or send
    If IsNull(Me.txtApptAttendees) = False Then
        If Me.txtApptAttendees <> "" Then
            .MeetingStatus = olMeeting
            .RequiredAttendees = Nz(Me.txtApptAttendees, "")
            .Send
        Else
            .Save
        End If
    Else
        .Save
    End If
        
End With

The isAppRunning function came from Daniel Pineault at Carda Consulting, should be able to find this through a simple Google search
 

vba_php

Forum Troll
Local time
Today, 14:31
Joined
Oct 6, 2019
Messages
2,884
very nice horton! i didn't test it, but it works better than mine, as he would've had to modify mine himself. if urs works, then he doesn't have to do a thing.
 

nhorton79

Registered User.
Local time
Tomorrow, 08:31
Joined
Aug 17, 2015
Messages
147
There’ll certainly be some modification required, just to make sure that fields line up with the correct fields in the database.

Saves as an appointment if there is null or “” in the textbox txtAttendees, otherwise it sends the meeting request.

Handles richtext body as well by using the inspector to generate as a message then copy back to the meeting request/appt.

Took a bit of faffing about..but got there with it.


Sent from my iPhone using Tapatalk
 

Users who are viewing this thread

Top Bottom