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(newstring[1]{"to@gmail.com"});composer.SetCcRecipients(newstring[1]{"cc@gmail.com"});composer.SetBccRecipients(newstring[1]{"bcc@gmail.com"});composer.SetSubject("Subject");composer.SetBody("Body",false);//Pass true if string is html contentcomposer.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(newstring[1]{"to@gmail.com"});composer.SetCcRecipients(newstring[1]{"cc@gmail.com"});composer.SetBccRecipients(newstring[1]{"bcc@gmail.com"});composer.SetSubject("Subject");composer.SetBody("Body",false);//Pass true if string is html contentcomposer.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(newstring[1]{"to@gmail.com"});composer.SetCcRecipients(newstring[1]{"cc@gmail.com"});composer.SetBccRecipients(newstring[1]{"bcc@gmail.com"});composer.SetSubject("Subject");composer.SetBody("Body",false);//Pass true if string is html contentcomposer.AddAttachment(fileByteData, mimeType,"file name");//fileByteData => file data bytescomposer.SetCompletionCallback((result, error) => {Debug.Log("Mail composer was closed. Result code: "+result.ResultCode);});composer.Show();