[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 120
  • Last Modified:

check outlook from access vba with a specific profile name

Check Outlook for several options:




If not open: Open with specific profile:
Dim objOL As Outlook.Application
    On Error Resume Next
    Set objOL = GetObject(, "Outlook.Application")
    If objOL Is Nothing Then
        Set objOL = CreateObject("Outlook.Application")
        objOL.Session.Logon ProfileName, , False, True
    End If
    Set OpenOL = objOL
    Set objOL = Nothing

Open in new window







If outlook is open :
Look for the profile name: if it is not a specific profile name then close it and open with a specific prpfile name...

Need code for checking outlook with a specific profile name ??


Function OpenOL(Optional ProfileName) As Outlook.Application
    Dim objOL As Outlook.Application
    On Error Resume Next
    Set objOL = GetObject(, "Outlook.Application")
    If objOL Is Nothing Then
        Set objOL = CreateObject("Outlook.Application")
        objOL.Session.Logon ProfileName, , False, True
    End If
    Set OpenOL = objOL
    Set objOL = Nothing
End Function

Open in new window




Thanks
Fordraiders
0
Fordraiders
Asked:
Fordraiders
1 Solution
 
Rgonzo1971Commented:
Hi,

pls try
Sub Macro()
Dim objOL As Outlook.Application
    On Error Resume Next
    Set objOL = GetObject(, "Outlook.Application")
    
    If Not objOL Is Nothing Then
        If objOL.Session.CurrentProfileName <> ProfileName Then
            objOL.Session.Logoff
            objOL.Session.Logon ProfileName, , False, True
        End If
    Else
        Set objOL = CreateObject("Outlook.Application")
        objOL.Session.Logon ProfileName, , False, True
    End If
    Set OpenOL = objOL
    Set objOL = Nothing

End Sub

Open in new window

Regards
0
 
FordraidersAuthor Commented:
thanks  !
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now