|
|
Title | Use ShellExecute to send mail using the default mail program |
Keywords | ShellExecute, mail, email, cc, bcc |
Categories | Office |
|
|
Use the ShellExecute API function to "open" a statement of the form (all on one line):
mailto:ann@msn.com
?cc=bob@msn.com
&bcc=cindy@msn.com
&subject=Hi
&body=Hello there!
To embed carriage return/line feed combinations in the message body, use the hexadecimal values %0D and %0A.
|
|
Private Sub cmdSend_Click()
ShellExecute hwnd, _
"open", _
"mailto:" & txtTo.Text & _
"?cc=" & txtCc.Text & _
"&bcc=" & txtBcc.Text & _
"&subject=" & txtSubject.Text & _
"&body=" & Replace(txtMessage.Text, vbCrLf, _
"%0D%0A"), _
vbNullString, vbNullString, _
SW_SHOW
End Sub
|
|
The result of all this is to pop up the system's default mail application with the indicated fields filled in. This works with VB 6 and Outlook Express. Other mail applications may not understand all of these fields.
Markus Seitz adds:
There seems to be a little variation in the way
Win2K and WinNt4 interpret things as well.
The same shell mail generated (in Outlook2K)
has about 9 lines in Win2K
and only 5 in WinNT4.
|
|
|
|
|
|