CISA FotoGallery

Statistiche

Tot. visite contenuti : 927957
Home Articoli tecnici VBA Lanciare il programma di posta predefinito

Lanciare il programma di posta predefinito

Option Compare Database

Public Declare Function MyRegOpenKeyExA Lib "advapi32.dll" _ Alias "RegOpenKeyExA" (ByVal hkey As Long, ByVal lpSubkey As String, _ ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkresult As _
Long) As Long

Public Declare Function MyRegQueryValueExA Lib "advapi32.dll" Alias _ "RegQueryValueExA" (ByVal hkey As Long, ByVal lpValueName As String, ByVal _ lpReserved As Long, ByVal lpType As Long, ByVal lpData As String, lpcbData As _
Long) As Long

Function ApriChiavePosta() As Long
Dim myName As String
Dim RegPath As String
Dim l_MyName As Long
Dim risultato As Long
Dim MyHandle As Long
RegPath = "SOFTWARE\Classes\mailto\shell\open\command"
risultato = MyRegOpenKeyExA(HKEY_LOCAL_MACHINE, RegPath, 0, KEY_QUERY_VALUE, MyHandle) If risultato = 0 Then ApriChiavePosta = MyHandle Else MsgBox "Errore n°: " & risultato ApriChiaveNomePosta = 0 End If

End Function

Function mail()

Dim myName As String
Dim RegPath As String
Dim l_MyName As Long
Dim KeyType As Long
Dim risultato As Long
l_MyName = 255
myName = String(l_MyName, vbNullChar)
risultato = ApriChiavePosta()
If risultato > 0 Then
risultato = MyRegQueryValueExA(risultato, RegPath, 0, KeyType, myName, l_MyName) If risultato = 0 Then MsgBox "Posta predefinita: " & MyName Else MsgBox "Errore nella lettura del nome della posta "
End If
Else
MsgBox "Problemi nell'apertura della chiave del registro."
End If
Shell (Left([myName], Len([myName]) - Len(Mid([myName], InStr([myName], " ")))))

End Function