[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

check outlook from access vba with a specific profile name

Posted on 2016-09-19
2
Medium Priority
?
108 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 2000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

650 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