我想用Android intent发送.png文件。我曾尝试使用WorldReadable权限在内部存储器中保存此文件,现在已保存到外部存储器。当我打开GMail客户端时,我的附件就在那里。但是,在Microsoft Exchange或Outlook应用程序中,附件不会显示,我必须手动添加它。意向发送电子邮件附件android。只适用于Gmail
我使用Xamarin.Android(MonoDroid),但任何Java解决方案也会有所帮助。 这是我的意图发送电子邮件的代码。
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setType("image/png"); // I also tried 'application/image'
intent.setData(Android.Net.Uri.Parse("mailto:" + address ?? string.Empty));
if (!string.isNullOrEmpty (attachment)) {
intent.putExtra (Android.Content.Intent.EXTRA_STREAM, Android.Net.Uri.fromFile(new Java.IO.File (Android.OS.Environment.getExternalStorageDirectory(), attachment)));
}
try {
_Context.startActivity(intent);
}catch(ActivityNotFoundException anfe) {
//Show prompt
}
我不知道为什么附件只显示在GMail中。我是否需要内容提供商?奇怪的是,它只出现在GMail中,而不是任何其他邮件应用程序。
除了意图设置为Intent.ActionSend我不得不改变的电子邮件地址intent.PutExtra(Intent.ExtraEmail),“ [email protected]'); – kevskree