Automatic email sender Outlook automation using VBScript
Everyday we use outlook to send so many mails. One of the most fantastic ways to automate sending a mail is through VBScript. We can use this for so many use cases for example:
- To send log files to predefined email addresses (or stakeholders) after a test execution.
- To trigger a test execution based on certain predefined subject line.
- Share failed screenshots to developers or BA as a routine.
- Send a request at a predefined time everyday with the help of task scheduler.
You get the idea right!
Here it is, an example to write your own custom automatic email sender outlook automation function to send a mail from outlook through VBScript.
In this code snippet, we use inbuilt object to interact with the outlook application through VBScript.
You can pass the following as String arguments.
- To Address
- Email Subject
- Body text
In the code above, you might have noticed the following line
This is the line where we create an object of Mail type to work on emails. Apart from sending emails, outlook provides so many functionalities, like creating a distribution list, creating appointment, meeting etc.
As we can send a mail in outlook using VBScript, we can also perform other tasks. You need to create an object of some other type to work on these things.
Please check the below table to understand what ItemType can be used for which purpose.
For example: If you want to work with Contacts, You need to create an object like below.
List of other Item types in Outlook
|A MailItem object.
|An AppointmentItem object.
|A ContactItem object.
|A TaskItem object.
|A JournalItem object.
|A NoteItem object.
|A PostItem object.
|A DistListItem object.