Solved

check outlook from access vba with a specific profile name

Posted on 2016-09-19
2
42 Views
Last Modified: 2016-09-20
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
Comment
Question by:fordraiders
2 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41805936
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
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 41807363
thanks  !
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
If you don't know how to downgrade, my instructions below should be helpful.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now