android - 发送带有 Intent 的电子邮件附件 android。仅适用于 Gmail

标签 android email android-intent xamarin.android email-attachments

我正在尝试发送一个带有 Android Intent 的 .png 文件。我尝试将此文件保存在具有 WorldReadable 权限的内部存储中,现在已保存到外部存储中。当我打开 GMail 客户端时,我的附件就在那里。但是,在 Microsoft Exchange 或 Outlook 应用程序中,附件不会出现,我必须手动添加它。

我正在使用 Xamarin.Android (MonoDroid),但任何 Java 解决方案也会有所帮助。 这是我发送带有 Intent 的电子邮件的代码。

        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 而不是任何其他邮件应用程序中。

最佳答案

您不需要 ContentProvider。

我在发送 JPEG 时做的事情基本相同,但使用 Intent.ActionSend 而不是 Intent.ActionSendTo

关于android - 发送带有 Intent 的电子邮件附件 android。仅适用于 Gmail,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19169516/

相关文章:

android - 使用平滑滚动将图像从 Assets 加载到 GridView

android - 如何自定义操作栏选项卡的字体

java - Android 游戏开发 - 我应该使用像 AndEngine 这样的框架吗?

php - 如何检测域是否已捕获所有接受电子邮件的策略?

python - 通过电子邮件使用 RPC?

android - 他们如何做到这一点? (安卓,滚动)

email - 我正在将我的域转移到 Azure。我需要能够使用我的 @url.com 电子邮件地址

android - Zxing - 我的应用不想启动相机

android - 我可以通过代码向同一 Android 设备发送 SMS,还是必须使用反向计费?

android - 一个 Activity 和另一个 Activity 之间的动画过渡