使用此代码向我发送电子邮件并与我合作。我现在想要的是同时发送带有消息的文件附件。
var email = new Intent(Android.Content.Intent.ActionSend);
email.PutExtra(Android.Content.Intent.ExtraEmail, new string[] {
"[email protected]",
"[email protected]"
});
email.PutExtra(Android.Content.Intent.ExtraCc, new string[] {
"[email protected]"
});
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);
最简单的方法是这样的:
string filename = "file.ext";
var filelocation = new File(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, filename);
Uri path = Android.Net.Uri.FromFile(filelocation);
Intent emailIntent = new Intent(Intent.ActionSend);
emailIntent.PutExtra(Intent.ExtraStream, path);
带有以下using语句:
using File = Java.IO.File;
using Uri = Android.Net.Uri;
Goodluck如有疑问,请随时还原