Cirrious.MvvmCross.Plugins.Email.Droid.MvxComposeEmailTask.ComposeEmail C# (CSharp) Method

ComposeEmail() public method

public ComposeEmail ( IEnumerable to, IEnumerable cc, string subject, string body, bool isHtml, IEnumerable attachments ) : void
to IEnumerable
cc IEnumerable
subject string
body string
isHtml bool
attachments IEnumerable
return void
        public void ComposeEmail(
            IEnumerable<string> to, IEnumerable<string> cc, string subject,
            string body, bool isHtml,
            IEnumerable<EmailAttachment> attachments)
        {
            // http://stackoverflow.com/questions/2264622/android-multiple-email-attachments-using-intent
            var emailIntent = new Intent(Intent.ActionSendMultiple);

            if (to != null)
            {
                emailIntent.PutExtra(Intent.ExtraEmail, to.ToArray());
            }
            if (cc != null)
            {
                emailIntent.PutExtra(Intent.ExtraCc, cc.ToArray());
            }
            emailIntent.PutExtra(Intent.ExtraSubject, subject ?? string.Empty);

            body = body ?? string.Empty;

            if (isHtml)
            {
                emailIntent.SetType("text/html");
                emailIntent.PutExtra(Intent.ExtraText, Html.FromHtml(body));
            }
            else
            {
                emailIntent.SetType("text/plain");
                emailIntent.PutExtra(Intent.ExtraText, body);
            }

            var attachmentList = attachments as IList<EmailAttachment> ?? attachments.ToList();
            if (attachmentList.Any())
            {
                var uris = new List<IParcelable>();

                DoOnActivity(activity =>
                {
                    foreach (var file in attachmentList)
                    {
                        var fileWorking = file;
                        File localfile;
                        using (var localFileStream = activity.OpenFileOutput(
                            fileWorking.FileName, FileCreationMode.WorldReadable))
                        {
                            localfile = activity.GetFileStreamPath(fileWorking.FileName);
                            fileWorking.Content.CopyTo(localFileStream);
                        }
                        localfile.SetReadable(true, false);
                        uris.Add(Uri.FromFile(localfile));
                        localfile.DeleteOnExit(); // Schedule to delete file when VM quits.
                    }
                });

                emailIntent.PutParcelableArrayListExtra(Intent.ExtraStream, uris);
            }

            // fix for GMail App 5.x (File not found / permission denied when using "StartActivity")
            StartActivityForResult(0, Intent.CreateChooser(emailIntent, string.Empty));
        }

Same methods

MvxComposeEmailTask::ComposeEmail ( IEnumerable to, IEnumerable cc, string subject, string body, bool isHtml, IEnumerable attachments ) : void
MvxComposeEmailTask::ComposeEmail ( string to, string cc, string subject, string body, bool isHtml ) : void
MvxComposeEmailTask