Visual Basic is a powerful scripting language from Microsoft that has many uses. Sending email with VBA is easy using the package. In this post we will demonstrate how to setup VBA with SMTP mailserver credentials and then send emails from code or tests.

Configure an SMTP server access

To send email in visual basic you need access to a MailServer (or API such as MailSlurp). In this example we will use a MailServer hosted by MailSlurp to configure our VBA client. If you already have a MailServer you can skip to the next step.

Create an SMTP client

Next, take the password, username, host, and port and configure the SMTP client:

Now send an email

Once configured we can use the instance to send an email: