[RELEASED] UTMail - Email Composition and Sending Plugin

3112390--235324--upload_2017-6-18_17-56-22.png

Documentation | Support Email

https://www.assetstore.unity3d.com/en/#!/content/90545
Unity 5.5+ (any edition)
Cross-platform:

  • macOS
  • Windows
  • Windows Store (Windows Phone 8.1, Windows 8.1/10, Universal 8.1, Universal 10)
  • Android
  • iOS

UTMail is Unity extension allowing developers composing and sending emails directly from C# code. It provides common cross-platform API and works on multiple platforms.

It’s an essential tool for integrating “Contact Support” functionality, and is also a very effective way of getting feedback for beta versions and internal test sessions. It may also be used for automatic or half-automatic reporting on crashes and other events.

Features:

  • Compose: opens a system email client with a content defined by your app. End-user can then optionally modify the message and send it. The email is sent from the end-user’s email address so you can give them a reply.
  • Send: uses SMTP to send emails directly, without showing any windows or popups.
  • SMTP with STARTTLS support on all supported platforms, unlike standard Unity SmtpClient, which makes it work with most modern secure SMTP servers.
  • Attachments.
  • Multiple To, Cc and Bcc recipients; Subject, Body, HTML Body and attachments are supported for both composing and sending.
  • A sample & test scene, which is completely functional even directly in the Unity Editor.

Universal Tools asset.
See also our popular UTNotifications - Professional Local & Push Notification Plugin.

1 Like

Is it possible to add inline images with this? If so, do you have an example of it?

Thanks!

Hi @UnravelingHell ,

No, currently it’s not supported: you can attach images, but not insert them in the message body (although, you of course can insert images from web with usual HTML tags).

Best regards,
Yuriy, Universal Tools team.

Hi @Yuriy-Ivanov ,

I’ts possible to send an e-mail using a fake “From” adress?

Best regards,

Chris.

Hi @Yuriy-Ivanov ,
Another question:
How can I attach a mp4 video file (less than 10 MB, stored on a local folder) to the e-mail message?

Best regards,

Chris.

Hello! I just started using this asset and am having trouble getting the sample scene to send an email. I keep getting this error message :
Windows MAPI doesn’t support IsBodyHtml property when composing an email. The property will be ignored (though an email client may still interpret the body as HTML).
See https://social.msdn.microsoft.com/Forums/en-US/8125da13-7d79-4a5a-82a5-57c8a322be78/uwp10240c-emailmessage-with-emailmessagebodykindhtml

Can someone please point me in the right direction, I do not understand Idisposable methods or how to use them.

Thanks in advance!

Did you ever figure out sending a video? I need to send a jpeg and can’t figure it out.

Nope, I asked the same question to the e-mail utmail@universal-tools.com, but I didn’t become an answer yet…

Hi @NexarChile ,

No, it’s impossible, not only because of lack in the UTMail API, but first of all because no modern email servers accept such messages for security reasons.

Hi @NexarChile & @kartoonist4351 ,

There are 5 ways of attaching anything in UTMail. Please see API reference for each of the 5 overloads of UT.MailMessage.AddAttachment:
https://universal-tools.github.io/UTMail/html_1.0/class_u_t_1_1_mail_message.html#a75352e735c1519a5851bba2b452d2114
https://universal-tools.github.io/UTMail/html_1.0/class_u_t_1_1_mail_message.html#a491a285ed3282eb19f0da22d88c47f34
https://universal-tools.github.io/UTMail/html_1.0/class_u_t_1_1_mail_message.html#a42ba1de9d2d66baf753c180d6905462b
https://universal-tools.github.io/UTMail/html_1.0/class_u_t_1_1_mail_message.html#a0121736da5cb168007e786793fb0eed7
https://universal-tools.github.io/UTMail/html_1.0/class_u_t_1_1_mail_message.html#acb50339a5859cac9a4f45811b5b72571

Most likely, the first overload is what you need, but there are other options as well (first of all the 2nd and 3rd overloads), feel free to choose one which suits your needs the best.

Best regards,
Yuriy, Universal Tools team.

Hi @DustinB ,

As stated, IsBodyHtml property is not supported when composing on Windows due to the limitations of Windows Messaging API (MAPI) & Universal Windows Platform (UWP) emailing API:

See also remarks to the property in UT.MailMessage class:

Best regards,
Yuriy, Universal Tools team.

OK @Yuriy-Ivanov thanks for your answer!

Best regards,

Chris.

Hey @Yuriy-Ivanov thanks for your help, you were right, it was very simple!

You have won a 5 star recommendation from me on the Asset Store!

As a last question: how can I catch errors on sending e-mails (for example if I don’t have Internet connection), to develop a Buffer, that send later the e-mails that couldn’t be sent?

Thanks!

Best regards,

Chris.

Hi @NexarChile ,

Right now UTMail will just log an exception or an error with either UnityEngine.Debug.LogError or UnityEngine.Debug.LogException (it depends on a platform and a specific issue). F.e. when there is no connection, SocketException would be logged. You can’t really handle that exception without a hook on Unity log (which is possible), as sending is done asynchronously and an exception may happen in a background thread. If you really have to handle that case, you can modify the asset source code to do something else (like store emails which failed to send), see Assets/UniversalTools/UTMail/Src/Mail.cs, lines 113 & 124 and Assets/UniversalTools/UTMail/Src/WSA/UTMailWSAImpl.cs, lines 44 & 50.

In the next update we’re gonna improve error handling on sending emails.

Best regards,
Yuriy, Universal Tools team.

Hi Yuriy-Ivanov,
lovely plugin, sends our mails and attachments no problem, but it does not seem to handle a replyto address.

I have try two ways of doing this:

using (var message = new UT.MailMessage()
.AddTo(toAddress)
.SetSubject(emailSubject)
.SetBody(HtmlEmailTemplate.text)
.SetBodyHtml(true)
)
{
message.ReplyTo = new UT.System.Net.Mail.MailAddress(smtpReplyToAddress);

AND

message.ReplyToList.Add(smtpReplyToAddress);

With the first variant the mail sends ok, but the ReplyTo is ignored.
With the second variant the mail silently fails, it just never arrives at all.

Any assistance would be much appreciated!
Many thanks
WagDan

Hi @WagDan ,

First of all, thank you for using UTMail.
Unfortunately, ReplyTo - is an undocumented setting, available in UTMail API on some platforms due to the way it’s implemented on these platforms. It’s not supported by the asset and won’t even compile if using on other platforms. You might use CC instead, so smtpReplyToAddress would receive an email when replying all. I’m afraid it’s the best you can get currently.

Best regards,
Yuriy, Universal Tools team.

Hi Yuriy,
many thanks for fast reply, at least we now know this limitation.
All the best
WagDan

Sorry just re-read again… which platforms might it work on? We are developing for iOS and Windows.
Thanks again!

None platforms actually, I’m afraid. It’s available in the API on non-Windows platforms, but ignored by UTMail anyway.

Hi,

I’m a happy user of UTMail (works like a charm) ! Now I’m wondering how to manage the case where the user does not have an email client configured (because he or she uses webmail only). Do you have any clue ? And first, is UTMail able to detect this situation ?

Thanks !
Olivier