Open Outlook using VBA in MS Access - Stack Overflow

PHOTO EMBED

Tue Oct 17 2023 14:43:41 GMT+0000 (Coordinated Universal Time)

Saved by @paulbarry #vb

Private Sub fireOutlook()
    Dim olShellVal As Long

    On Error GoTo FIREOUTLOOK_ERR
    Set g_olApp = GetObject(, "Outlook.Application") ' If outlook is open will create obj
    ' If closed this will goto the error handler and then resume
    If g_olApp Is Nothing Then ' This checks if object was created
        olShellVal = Shell("OUTLOOK", vbNormalNoFocus) ' Opens Outlook
        Set g_olApp = CreateObject("Outlook.Application") ' Creates the Object
    End If
FIREOUTLOOK_EXIT:
    Exit Sub
FIREOUTLOOK_ERR:
    If g_olApp Is Nothing Then
        Err.Clear
        Resume Next
    Else
        MsgBox Err.Description, , "Error Number: " & Err.Number
    End If
    GoTo FIREOUTLOOK_EXIT
End Sub
content_copyCOPY

https://stackoverflow.com/questions/44974735/open-outlook-using-vba-in-ms-access