Option Compare Database
Option Explicit
Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Function MAPISendMail Lib "MAPI32.DLL" Alias "BMAPISendMail" _
(ByVal Session As Long, ByVal UIParam As Long, Message As MAPIMessage, _
Recipient() As MapiRecip, File() As MapiFile, ByVal Flags As Long, _
ByVal Reserved As Long) As Long
Public Function RunMAPISendMail()
Dim hModule As Long
Dim lpProc As Long
Dim FreeLib As Boolean
Dim ret As Long
Dim strDllPath As String
strDllPath = "C:\Program Files\Outlook Express\"
hModule = GetModuleHandle(strDllPath & "MAPI32.DLL")
If hModule = 0 Then
hModule = LoadLibrary(strDllPath & "MAPI32.DLL")
FreeLib = True
End If
If hModule Then
lpProc = GetProcAddress(hModule, "BMAPISendMail")
If lpProc <> 0 Then
returnVal = MAPISendMail()
End If
Exported = (lpProc <> 0)
End If
If FreeLib Then Call FreeLibrary(hModule)
End Function