How to determine type of email client is installed using VBA

Posted on 2011-05-10
Last Modified: 2012-08-14

I am working on an Access 2007 application where I have installed a generic error handler.  There is a email function that I am trying to implement that will email a report.  I know how to use either outlook or lotus notes to send email via automation from access.  However, I want to be determine what type of email client is installed.  For example, if a user has Lotus Notes installed, the report would be sent via lotus note, if a user has outlook installed, the report would be sent via outlook.  How do I determine the mail client that is installed on a machine via vba.  I'm thinking it might require a windiows api call
Question by:chtullu135
    LVL 10

    Accepted Solution

    vba and vbscript:

    <pre>Sub GetMailClient()
    Dim RegVal As String, MailProg As String
    Dim CharPos As Integer, RegValLength As Integer
    Dim WshShell
    Set WshShell = CreateObject("")
    RegVal = WshShell.regread("HKEY_CLASSES_ROOTmailtoshellopen command")
    Set WshShell = Nothing
    RegValLength = Len(RegVal)
    For CharPos = RegValLength To 0 Step -1
    On Error Resume Next 'In case there's no path
    If Mid(RegVal, CharPos, 1) = "" Then
    MailProg = Mid(RegVal, CharPos + 1)
    Exit For
    End If
    Next CharPos
    RegValLength = Len(MailProg)
    For CharPos = 1 To RegValLength Step 1
    If Mid(MailProg, CharPos, 1) = "." Then
    MailProg = Mid(MailProg, 1, CharPos + 3)
    Exit For
    End If
    Next CharPos
    MailProg = """" & MailProg & """" 'enclose in quotes just in case of long filename
    MsgBox "Your default e-mail client is: " & MailProg
    End Sub

    Open in new window

    LVL 21
    LVL 21

    Assisted Solution

    by:Boyd (HiTechCoach) Trimmell, Microsoft Access MVP
    There is a reg key for this. I could not get GlobaLevel's code to work.

     reg key

    Author Comment

    Thanks for the info.  I'm sorry for the delay in responding,  I'm in the process of addressing some other issues concerning another database.  I'll get back to this problem in a day.  

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
    In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

    755 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

    19 Experts available now in Live!

    Get 1:1 Help Now