Use this code to send an email to me and work with me. What I want now is to send a file attachment also with the message.
var email = new Intent(Android.Content.Intent.ActionSend);
email.PutExtra(Android.Content.Intent.ExtraEmail, new string[] {
"susairajs@outlook.com",
"susairajs18@gmail.com"
});
email.PutExtra(Android.Content.Intent.ExtraCc, new string[] {
"susairajs18@live.com"
});
email.PutExtra(Android.Content.Intent.ExtraSubject, "Hello Xamarin");
email.PutExtra(Android.Content.Intent.ExtraText, "Hello Xamarin This is My Test Mail...!");
email.SetType("message/rfc822");
StartActivity(email);
sample.txt in Assets folder. Set the Build Action to AndroidAsset.
The Path of the txt file.
//android_asset/sample.txt
Usage:
btnSend.Click += delegate
{
Android.Net.Uri file = Android.Net.Uri.FromFile(new
Java.IO.File("//android_asset/sample.txt"));
var email = new Intent(Android.Content.Intent.ActionSend);
email.PutExtra(Android.Content.Intent.ExtraEmail,
new string[] { "xxxxxx@xxxxx.com" });
//email.PutExtra(Android.Content.Intent.ExtraCc,
//new string[] { "something@gmail.com" });
email.PutExtra(Android.Content.Intent.ExtraSubject, "Awesome File");
email.PutExtra(Android.Content.Intent.ExtraText, "See attached file");
email.PutExtra(Android.Content.Intent.ExtraStream, file);
email.SetType("message/rfc822");
StartActivity(Intent.CreateChooser(email, "Send email..."));
};