• GPL
    autoit
_LaunchDefaultMailClient()
A simple function that launches the default mail client of the current user. Should be helpful for some projects.
Code
  1. ;===============================================================================
  2. ; Function Name:    _LaunchDefaultMailClient()
  3. ; Description:      Open default mail client
  4. ; Parameter(s):     None
  5. ; Requirement(s):   None
  6. ; Return Value(s):  On Success - Process ID of e-mail client
  7. ;                   On Failure - Returns:
  8. ;                                                                               1-Reading of the registry Failed
  9. ;                                                                               2-Getting the Path Of the Default Mail Client Failed
  10. ;                                                                               3-Run Failed
  11. ; Author(s):        Brett Francis <francisb[at]student[dot]jpc[dot]qld[dot]edu[dot]au>
  12. ; Thanks:                       GaryFrost
  13. ;                                       Zedna
  14. ;                                       MrCreator
  15. ; Note(s):                      For Some reason, Wont work for Opera.  Will Update Soon.
  16. ;===============================================================================
  17. ;
  18. Func _LaunchDefaultMailClient()
  19.         Local $Old_Opt_EES = Opt("ExpandEnvStrings", 1)
  20.         Local $iRetError = 0, $iRetValue = 0
  21.         Local $ReadDefMailClient, $ReadCommand
  22.  
  23.         $ReadDefMailClient = RegRead("HKLM\SOFTWARE\Clients\Mail", "")
  24.         If @error Or $ReadDefMailClient = "" Then $iRetError = 1
  25.  
  26.         If $iRetError = 0 Then
  27.                 $ReadCommand = RegRead("HKLM\SOFTWARE\Clients\Mail\" & $ReadDefMailClient & "\shell\open\command", "")
  28.                 If @error Or $ReadCommand = "" Then $iRetError = 2
  29.         EndIf
  30.  
  31.         If $iRetError = 0 Then
  32.                 If StringRegExp($ReadCommand, '"(.*)"') Then _
  33.                                 $ReadCommand = StringMid($ReadCommand, 2, StringInStr($ReadCommand, '"', 0, 2) - 2)
  34.                 If StringInStr($ReadCommand, '/') Then _
  35.                                 $ReadCommand = StringLeft($ReadCommand, StringInStr($ReadCommand, '/', 0, -1))
  36.         EndIf
  37.  
  38.         If $iRetError = 0 Then
  39.                 $ReadCommand = StringStripWS($ReadCommand, 3)
  40.                 If Not FileExists($ReadCommand) Then $iRetError = 3
  41.         EndIf
  42.  
  43.         If $iRetError = 0 Then
  44.                 Local $iRetValue = Run($ReadCommand)
  45.                 If @error Then $iRetError = 4
  46.         EndIf
  47.  
  48.         Opt("ExpandEnvStrings", $Old_Opt_EES)
  49.         Return SetError($iRetError, 0, $iRetValue)
  50. EndFunc   ;==>_LaunchDefaultMailClient