Essential Kit Tutorials
DocumentationDownload
Latest(v3)
Latest(v3)
  • Introduction
  • Features Overview
  • Whats new in v3
    • Version 3 vs Version 2
    • Release Notes
    • Upgrade from V2
  • Plugin Overview
    • Settings
    • Folder Structure
    • Installation FAQ
    • Upgrade Guide
  • Features
    • 📒Address Book
      • Setup
      • Usage
      • Testing
      • FAQ
    • App Shortcuts
      • Setup
      • Usage
    • 🆕App Updater
      • Setup
      • Usage
    • 💲Billing Services
      • Setup
        • iOS
        • Android
      • Usage
      • Testing
        • iOS
        • Android
      • FAQ
    • ☁️Cloud Services
      • Setup
        • iOS
        • Android
      • Usage
      • Testing
      • FAQ
    • 🔗Deep Link Services
      • Setup
        • iOS
        • Android
      • Usage
      • Testing
      • FAQ
    • 🛠️Utilities (Extras)
      • Usage
    • 💯Game Services
      • Setup
        • iOS
        • Android
      • Usage
      • FAQ
    • 📸Media Services
      • Setup
      • Usage
      • FAQ
    • 📆Native UI
      • Setup
      • Usage
      • FAQ
      • Examples
        • Login Dialog
    • Network Services
      • Setup
      • Usage
      • FAQ
    • ⏰Notification Services
      • Setup
        • iOS
        • Android
      • Usage
      • Examples
        • Nudge to come-back to the game
      • FAQ
    • ⭐Rate My App
      • Setup
      • Usage
      • FAQ
    • 🤝Sharing
      • Setup
      • Usage
        • Message Composer
        • Mail Composer
        • Social Share Composer
        • Share Sheet
      • FAQ
      • Examples
        • Add Attachment Example
    • Task Services
      • Setup
      • Usage
    • 🌏Web View
      • Setup
      • Usage
      • FAQ
      • Examples
        • Loading Pdf File
  • Notes
    • Resolving Android Gradle Build Errors
    • Google Play Services Authentication
    • Target API Level vs Min API Level
    • Handling Refunds for In-App Purchases (Billing Services)
Powered by GitBook
On this page
  • Send a text mail
  • Send a mail with screenshot
  • Send a mail with an attachment

Was this helpful?

Edit on GitHub
  1. Features
  2. Sharing
  3. Usage

Mail Composer

Once after importing the name space, you can send a mail with MailComposer class.

You can set the following to the MailComposer.

  • To Recipients

  • Cc Recipients

  • Bcc Recipients

  • Subject

  • Body

  • Screenshot/Image

  • Attachment (any file)

Before accessing any of the MailComposer features you need to check if it's allowed to send mails through mail client apps on the user's device.

bool canSendMail = MailComposer.CanSendMail();

Once you get the results from above methods, you need to add content to the mail composer based on the above status.

Send a text mail

MailComposer composer = MailComposer.CreateInstance();
composer.SetToRecipients(new string[1]{"to@gmail.com"});
composer.SetCcRecipients(new string[1]{"cc@gmail.com"});
composer.SetBccRecipients(new string[1]{"bcc@gmail.com"});

composer.SetSubject("Subject");
composer.SetBody("Body", false);//Pass true if string is html content
composer.SetCompletionCallback((result, error) => {
    Debug.Log("Mail composer was closed. Result code: " + result.ResultCode);
});
composer.Show();

Send a mail with screenshot

MailComposer composer = MailComposer.CreateInstance();
composer.SetToRecipients(new string[1]{"to@gmail.com"});
composer.SetCcRecipients(new string[1]{"cc@gmail.com"});
composer.SetBccRecipients(new string[1]{"bcc@gmail.com"});

composer.SetSubject("Subject");
composer.SetBody("Body", false);//Pass true if string is html content
composer.AddScreenshot("screenshot file name");
composer.SetCompletionCallback((result, error) => {
    Debug.Log("Mail composer was closed. Result code: " + result.ResultCode);
});
composer.Show();

Send a mail with an attachment

MailComposer composer = MailComposer.CreateInstance();
composer.SetToRecipients(new string[1]{"to@gmail.com"});
composer.SetCcRecipients(new string[1]{"cc@gmail.com"});
composer.SetBccRecipients(new string[1]{"bcc@gmail.com"});

composer.SetSubject("Subject");
composer.SetBody("Body", false);//Pass true if string is html content
composer.AddAttachment(fileByteData, mimeType, "file name");//fileByteData => file data bytes
composer.SetCompletionCallback((result, error) => {
    Debug.Log("Mail composer was closed. Result code: " + result.ResultCode);
});
composer.Show();

It's allowed to add multiple attachments!

PreviousMessage ComposerNextSocial Share Composer

Last updated 5 months ago

Was this helpful?

🤝