There’s a huge opportunity for email games, as I wrote in a previous post. There’s also a need for email within games. Unity is a popular tool for publishing multi-platform games. But what about sending email from Unity? I decided to share how I did this with SendGrid.
First, to send using SMTP is really simple. You can use the System.Net.Mail library to use the MailMessage and SmtpClient classes:
To use SendGrid’s SMTP API all you have to do is use one line of code:
Now to send using the Web API is even simpler. All you have to do is make a simple HTTP request:
As with SMTP, using the SMTP API with the Web API only takes one line:
I created a sample project with two buttons, clicking one them will send an email either using SMTP, or the Web API.
One way to make use of email inside your game could be, for example, tracking how much time the user spends playing with a character, and sending him an email with a desktop screenshot of it. Or sending an email with a nice screenshot the moment the player gets an achievement.
How else do you think emails could be useful inside a game?