Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Detecting email client (VB 6/Access 97)

    Either in VB or VBA, is there a way to detect which email client is selected?

    I have used a method to see if a .dll is present (for Outlook 97, 2000 or express), but more than one may be installed so I'd like to be able to detect which program is in the email box in internet explorer/tools/internet options/programs

    At a guess i'd say its stored in the registry somewhere but im not sure and havent had any luck in finding it. Any help would be much appreciated.

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Detecting email client (VB 6/Access 97)

    Where are you trying to determine this Phil, from VB 6 or from Access 97? The methods may not be the same.
    Charlotte

  3. #3
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detecting email client (VB 6/Access 97)

    Either will do. But preferably VB. I put the VBA bit in incase someone happened to know that method, therefore I could use any keywords etc to find out how the VB version works.
    As with most topics, the "how to" is out there, its just knowing what to type to find it!

    Eventually I could do with knowing both as the feature is needed for both VB and Access programs.

  4. #4
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Detecting email client (VB 6/Access 97)

    Is it possible to find it by running a registry monitor and then clicking a mailto: link in some program? This should show you which registry keys are being accessed.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  5. #5
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Detecting email client (VB 6/Access 97)

    By reading then parsing the value at this reg key you can determine the default email client:

    HKEY_CLASSES_ROOTmailtoshellopencommand

    Mine returns: "C:PROGRA~1MICROS~2Office10OUTLOOK.EXE" -c IPM.Note /m "%1"

    The following code was contributed by Macropod, who never could resist wrapping a
    little code around a good registry key and value. (Nice work, Paul).

    <pre>Sub GetMailClient()
    Dim RegVal As String, MailProg As String
    Dim CharPos As Integer, RegValLength As Integer
    Dim WshShell
    Set WshShell = CreateObject("Wscript.shell")
    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
    </pre>


    I just had to give it a go using regular expressions:
    (with apologies to macropod)

    <pre>Sub GetMailClient()
    Dim MailProg As String
    Dim WshShell
    Dim RegEx, regMatch

    Set WshShell = CreateObject("Wscript.shell")
    Set RegEx = CreateObject("vbscript.regexp")

    With RegEx
    .Pattern = "w*.w{3}"
    .IgnoreCase = True
    End With

    MailProg = WshShell.regread("HKEY_CLASSES_ROOTmailtoshellopen command")
    Set WshShell = Nothing
    Set regMatch = RegEx.Execute(MailProg)
    MailProg = Mid(regMatch(0).Value, 2)
    Set RegEx = Nothing

    MailProg = """" & MailProg & """" 'enclose in quotes just in case of long filename
    MsgBox "Your default e-mail client is: " & MailProg
    End Sub
    </pre>

    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •