Essential Kit Tutorials
DocumentationDownload
Version 2
Version 2
  • Introduction
  • Features
  • Version 2 vs Version 1
  • Release Notes
    • ✅Version 2.7.4
    • Version 2.7.3
    • Version 2.7.2
    • Version 2.7.1
    • Version 2.7.0
    • Older Versions
      • Version 2.6.1
      • Version 2.6.0
      • Version 2.5.1
      • Version 2.5.0
      • Version 2.4.1
      • Version 2.4.0
      • Version 2.3.1
      • Version 2.3.0
      • Version 2.2.1
      • Version 2.2.0
      • Version 2.1.1
      • Version 2.1.0
      • Version 2.0.4
      • Version 2.0.3
      • Version 2.0.2
      • Version 2.0.1
      • Version 2.0.0
  • Plugin Overview
    • Settings
    • Folder Structure
    • Installation FAQ
    • Localisation
  • Address Book
    • Overview
    • Use Cases
    • Setup
    • Usage
    • Testing
    • FAQ
  • Billing Services
    • Overview
    • Use Cases
    • Setup
      • iOS
      • Android
    • Usage
    • Testing
      • iOS
      • Android
    • FAQ
  • Cloud Services
    • Overview
    • Use Cases
    • Setup
      • iOS
      • Android
    • Usage
    • Testing
    • FAQ
  • Deep Link Services
    • Overview
    • Use Cases
    • Setup
      • iOS
      • Android
    • Usage
    • Testing
    • FAQ
  • Extras (Utilities)
    • Overview
    • Usage
  • Game Services
    • Overview
    • Use Cases
    • Setup
      • iOS
      • Android
    • Usage
    • FAQ
  • Media Services
    • Overview
    • Use Cases
    • Setup
    • Usage
    • FAQ
  • Native UI
    • Overview
    • Use Cases
    • Setup
    • Usage
    • FAQ
  • Network Services
    • Overview
    • Use Cases
    • Setup
    • Usage
    • FAQ
  • Notification Services
    • Overview
    • Use Cases
    • Setup
      • iOS
      • Android
    • Usage
    • FAQ
  • Rate My App
    • Overview
    • Use Cases
    • Setup
    • Usage
    • FAQ
  • Sharing
    • Overview
    • Use Cases
    • Setup
    • Usage
      • Message Composer
      • Mail Composer
      • Social Share Composer
      • Share Sheet
    • FAQ
  • Web View
    • Overview
    • Use Cases
    • Setup
    • Usage
    • FAQ
  • Notes
    • Resolving Android Gradle Build Errors
    • Google Play Services Authentication
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. Sharing
  2. 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 4 years ago

Was this helpful?