Last active
March 28, 2018 20:59
-
-
Save prashantvc/5213961 to your computer and use it in GitHub Desktop.
Send email with multiple attachments (Xamarin.Android)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Email(Context context, string emailTo, string emailCC, string subject, string emailText, List<string> filePaths) | |
{ | |
var email = new Intent(Intent.ActionSendMultiple); | |
email.SetType("text/plain"); | |
email.PutExtra(Intent.ExtraEmail, new string[]{emailTo}); | |
email.PutExtra(Intent.ExtraCc, new string[]{emailCC}); | |
var uris = new List<IParcelable>(); | |
filePaths.ForEach(file=> { | |
var fileIn = new File(file); | |
var uri = Android.Net.Uri.FromFile(fileIn); | |
uris.Add(uri); | |
}); | |
email.PutParcelableArrayListExtra(Intent.ExtraStream, uris); | |
context.StartActivity(Intent.CreateChooser(email, "Send mail...")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment