Email Sample Applications
The following sample applications are included when you purchase the Visual Basic 6 Tutorial Download Package or the Visual Basic 6 "Extra" Sample Applications from The VB Programmer.
1. Send Emails Using MAPI
This sample application demonstrates how to send emails from your VB program using MAPI (Messaging Application Programming Interface). Using MAPI enables your VB program to send emails using the user's default email program (it need not be MS-Outlook).
The interface for the sample application is shown below. Note that if you want to send the email to more than one recipient, just enter the email addresses for those recipients on separate lines in the multi-line textbox for Recipients as shown below. For Subject and Body, just type any text.
For attachments, click the Add File button and a dialog box will appear, allowing you to navigate to the file you want to send:
The name of the file that you select will then be added to the Attachments list as shown below. You can repeat the "Add File" process for as many attachments that you want to send. If you add a file in error, you can select it from the list and click the "Remove File" button to remove it from the list.
After you have populated the fields on this form, you can click the "Send Email" button to send the email (the code behind the button populates the appropriate MAPI objects and properties with the data you have provided on the form and then sends the email).
2. Send Emails Using Outlook
This sample application demonstrates how to send emails from your VB program using MS-Outlook. It behaves identically to the MAPI sample application, with the additional feature of using the Outlook Address Book. In this application, you can choose to load the address book by clicking the "Load Address Book" button (the address book will not be loaded by default, because if there are many entries, processing time to load those entries can be significant). If you choose to load the address book, then you can check the names of those persons you wish to be added as a recipient.
After you have populated the other fields on this form in the same manner as the previous sample application, you can click the "Send Email" button to send the email (the code behind the button populates the appropriate Outlook objects and properties with the data you have provided on the form and then sends the email).