我想用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