Sending Emails Using MS-Outlook
The following sample applications are included when you purchase the VB 2010 Tutorial Download Package or the VB 2010 "Extra" Sample Applications from The VB Programmer. |
This sample application demonstrates how to send emails from your VB program using 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.
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.
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 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).