Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
 
 
 
 
TitleUse ShellExecute to send mail using the default mail program
KeywordsShellExecute, mail, email, cc, bcc
CategoriesOffice
 
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.
 
 
Copyright © 1997-2001 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated