Home
Blog
Software
Projects
Tutorials
About Me
Portfolio
0 Stars
1 Star
2 Stars
3 Stars
4 Stars
5 Stars
Download Script (.au3)
AutoIt Thread
_LaunchDefaultMailClient()
A simple function that launches the default mail client of the current user. Should be helpful for some projects.
Code
;===============================================================================
; Function Name: _LaunchDefaultMailClient()
; Description: Open default mail client
; Parameter(s): None
; Requirement(s): None
; Return Value(s): On Success - Process ID of e-mail client
; On Failure - Returns:
; 1-Reading of the registry Failed
; 2-Getting the Path Of the Default Mail Client Failed
; 3-Run Failed
; Author(s): Brett Francis <francisb[at]student[dot]jpc[dot]qld[dot]edu[dot]au>
; Thanks: GaryFrost
; Zedna
; MrCreator
; Note(s): For Some reason, Wont work for Opera. Will Update Soon.
;===============================================================================
;
Func
_LaunchDefaultMailClient
(
)
Local
$Old_Opt_EES
=
Opt
(
"ExpandEnvStrings"
,
1
)
Local
$iRetError
=
0
,
$iRetValue
=
0
Local
$ReadDefMailClient
,
$ReadCommand
$ReadDefMailClient
=
RegRead
(
"HKLM\SOFTWARE\Clients\Mail"
,
""
)
If
@error
Or
$ReadDefMailClient
=
""
Then
$iRetError
=
1
If
$iRetError
=
0
Then
$ReadCommand
=
RegRead
(
"HKLM\SOFTWARE\Clients\Mail\"
&
$ReadDefMailClient
&
"\shell\open\command"
,
""
)
If
@error
Or
$ReadCommand
=
""
Then
$iRetError
=
2
EndIf
If
$iRetError
=
0
Then
If
StringRegExp
(
$ReadCommand
,
'
"(.*)"
'
)
Then
_
$ReadCommand
=
StringMid
(
$ReadCommand
,
2
,
StringInStr
(
$ReadCommand
,
'
"', 0, 2) - 2)
If StringInStr($ReadCommand, '/') Then _
$ReadCommand = StringLeft($ReadCommand, StringInStr($ReadCommand, '/', 0, -1))
EndIf
If $iRetError = 0 Then
$ReadCommand = StringStripWS($ReadCommand, 3)
If Not FileExists($ReadCommand) Then $iRetError = 3
EndIf
If $iRetError = 0 Then
Local $iRetValue = Run($ReadCommand)
If @error Then $iRetError = 4
EndIf
Opt("
ExpandEnvStrings
", $Old_Opt_EES)
Return SetError($iRetError, 0, $iRetValue)
EndFunc ;==>_LaunchDefaultMailClient