| Public Function MailToURL(sAddy As String, sSubject As String, _
sBody As String)
MailToURL = "mailto:" & URLEncode(sAddy) & "?subject=" & _
URLEncode(sSubject) & "&body=" & URLEncode(sBody)
End Function
Public Function URLEncode(sPlain As String) As String
Dim i As Long
For i = 1 To Len(sPlain)
Select Case Asc(UCase(Mid(sPlain, i, 1)))
Case Asc("A") To Asc("Z")
URLEncode = URLEncode & Mid(sPlain, i, 1)
Case Else
URLEncode = URLEncode & "%" & _
Right("00" & Hex(Asc(Mid(sPlain, i, 1))), 2)
End Select
Next
End Function
|
| Private 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
Private Const SW_NORMAL = 1
Private Sub Form_Load()
Dim sAddy As String
Dim sSubject As String
Dim sBody As String
sAddy = "scott@example.com"
sSubject = "Example Message"
sBody = "This is just an example message" & vbNewLine & _
"Please disregard"
ShellExecute 0, "open", MailToURL(sAddy, sSubject, sBody), _
"", "", SW_NORMAL
End Sub
|