MissouriTiger
Programmer
I found this on the web and want to share it. Worked like a charm! A demo is posted at the following address (look for link at bottom of the web page):
Launch e-mail Client -This tip will show you how to launch the default e-mail client.
Declarations:
Declare Function ShellExecute Lib "shell32.dll" _Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Function Code:
Function LaunchEmail(email As String, Form As Form) As Boolean
Dim ReturnVal As Long
ReturnVal = ShellExecute(Form.hwnd, "open", "mailto:" & email, "", App.Path, 0)
If ReturnVal < 31 Then 'Error
MsgBox "There was a problem executing the default e-mail client. Check that it is properly installed.", vbInformation, App.Title
LaunchEmail = False
Else If ReturnVal = 32 Then 'Error
MsgBox "There no file association for an e-mail client.", vbInformation, App.Title
LaunchEmail = False
Else 'Everything Worked
LaunchEmail = True
End If
End Function
Use:
Dim RetVal As BooleanRetVal = LaunchEmail("tom@vbland.hypermart.net", Me)
Launch e-mail Client -This tip will show you how to launch the default e-mail client.
Declarations:
Declare Function ShellExecute Lib "shell32.dll" _Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Function Code:
Function LaunchEmail(email As String, Form As Form) As Boolean
Dim ReturnVal As Long
ReturnVal = ShellExecute(Form.hwnd, "open", "mailto:" & email, "", App.Path, 0)
If ReturnVal < 31 Then 'Error
MsgBox "There was a problem executing the default e-mail client. Check that it is properly installed.", vbInformation, App.Title
LaunchEmail = False
Else If ReturnVal = 32 Then 'Error
MsgBox "There no file association for an e-mail client.", vbInformation, App.Title
LaunchEmail = False
Else 'Everything Worked
LaunchEmail = True
End If
End Function
Use:
Dim RetVal As BooleanRetVal = LaunchEmail("tom@vbland.hypermart.net", Me)