The full source for this article is available here.

It is very easy to send email with ASNA Visual RPG. The core enablers are baked into the .NET Framework in these two namespaces:

The documentation for the System.Net.Mail.SmtpClient class says that because this class "doesn’t support many modern protocols" it is deprecated and that you should use the Nuget MailKit package to send emails. However, the System.Net.Mail.SmtpClient has worked fine for me for a long time with the SMTP services I use. It appears to be obsolete only when used with Xamarin. Read more about this issue here.

The code is at this GitHub repo and provides everything you need to be sending emails quickly. You can also read the fully annotated code here.

SMTP configuration

The project needs an App.config file that provides your SMTP server configuration details. An App.config.sample file is included to use as a base for your tailored App.config file.

It needs:

The App.config.sample file:

Copy the App.config.sample file to App.config and fill in your SMTP provider details.

This project was compiled with AVR 15x. This project be opened and used with higher versions of AVR. You can’t open this project with an earlier version of AVR, but if you copy and pasted the code as-in to older versions I am pretty sure it works at least down to AVR 12.x.

Send an email

This repo provides a reusable Emailer class that you can use to send emails through an SMTP server with ASNA Visual RPG. The project code on GitHub includes a more detailed example, but the short version of sending email with the Emailer class looks like this:

The Emailer has been used successfully with several email providers including Office 365, GMail, and Zoho. If you use two-factor authentication with your SMTP provider, check its documentation. Generally, with two-factor authentication you’ll need to generate a special-case password.