Class MailComposer
The MailComposer class provides an interface to compose and send an email message.
Inheritance
Namespace: VoxelBusters.EssentialKit
Assembly: cs.temp.dll.dll
Syntax
public sealed class MailComposer : NativeFeatureBehaviour
Examples
The following code example shows how to compose mail.
using UnityEngine;
using System.Collections;
using VoxelBusters.EssentialKit;
public class ExampleClass : MonoBehaviour
{
public void Start()
{
if (MailComposer.CanSendMail())
{
// create new instance and populate fields
MailComposer newComposer = MailComposer.CreateInstance();
newComposer.SetSubject("Example");
newComposer.SetBody("Lorem ipsum dolor sit amet");
newComposer.AddScreenshot("screenshot.jpg");
newComposer.SetCompletionCallback(OnMailComposerClosed);
newComposer.Show();
}
else
{
// device doesn't support sending emails
}
}
private void OnMailComposerClosed(MailComposerResult result, Error error)
{
// add your code
}
}
Methods
AddAttachment(Byte[], String, String)
Adds the specified data as an attachment of the email.
Declaration
public void AddAttachment(byte[] data, string mimeType, string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | data | The data of the file that has to be added as an attachment. |
System.String | mimeType | The MIME type of the specified data. |
System.String | fileName | The filename of the specified data. |
AddImage(Texture2D, String, TextureEncodingFormat)
Adds specified image as an attachment of the email.
Declaration
public void AddImage(Texture2D image, string fileName, TextureEncodingFormat textureEncodingFormat = null)
Parameters
Type | Name | Description |
---|---|---|
Texture2D | image | The image that has to be added as an attachment. |
System.String | fileName | The preferred filename to associate with the image. |
TextureEncodingFormat | textureEncodingFormat | Texture encoding format. |
AddScreenshot(String)
Captures a screenshot and adds it as an attachment of the email.
Declaration
public void AddScreenshot(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | The preferred filename to associate with the image. |
AwakeInternal(Object[])
Declaration
protected override void AwakeInternal(object[] args)
Parameters
Type | Name | Description |
---|---|---|
System.Object[] | args |
CanSendMail()
Returns a Boolean indicating whether the current device is able to send email.
Declaration
public static bool CanSendMail()
Returns
Type | Description |
---|---|
System.Boolean |
|
CreateInstance()
Initializes a new instance of the MailComposer class.
Declaration
public static MailComposer CreateInstance()
Returns
Type | Description |
---|---|
MailComposer |
DestroyInternal()
Declaration
protected override void DestroyInternal()
GetFeatureName()
Declaration
protected override string GetFeatureName()
Returns
Type | Description |
---|---|
System.String |
IsAvailable()
Declaration
public override bool IsAvailable()
Returns
Type | Description |
---|---|
System.Boolean |
SetBccRecipients(String[])
Sets the initial recipients to include in the email’s “Bcc” field.
Declaration
public void SetBccRecipients(params string[] values)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | values | An array of string values, each of which contains the email address of a single recipient. |
SetBody(String, Boolean)
Sets the initial body text to include in the email.
Declaration
public void SetBody(string value, bool isHtml = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The initial body text of the message. The text is interpreted as either plain text or HTML depending on the value of the isHTML parameter.. |
System.Boolean | isHtml | Specify YES if the body parameter contains HTML content or specify NO if it contains plain text. |
SetCcRecipients(String[])
Sets the initial recipients to include in the email’s “Cc” field.
Declaration
public void SetCcRecipients(params string[] values)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | values | An array of string values, each of which contains the email address of a single recipient. |
SetCompletionCallback(EventCallback<MailComposerResult>)
Specify the action to execute after the composer is dismissed.
Declaration
public void SetCompletionCallback(EventCallback<MailComposerResult> callback)
Parameters
Type | Name | Description |
---|---|---|
EventCallback<MailComposerResult> | callback | The action to be called on completion. |
SetSubject(String)
Sets the initial text for the subject line of the email.
Declaration
public void SetSubject(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The text to display in the subject line. |
SetToRecipients(String[])
Sets the initial recipients to include in the email’s “To” field.
Declaration
public void SetToRecipients(params string[] values)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | values | An array of string values, each of which contains the email address of a single recipient. |
Show()
Shows the email composer interface with values initially set.
Declaration
public void Show()