如何通过电子邮件发送图片在Android中,previewed但不要执着..? [英] How to send a picture via email in Android, previewed but NOT attached..?

查看:163
本文介绍了如何通过电子邮件发送图片在Android中,previewed但不要执着..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的邮件意图发送图片preVIEW。
我不想进行安装,我只是希望它显示出来。

I want to send a picture preview in my mail Intent. I dont want to attach it, i just want it to be shown.

这是我的意图:

String textToSend = getString(R.string.mailHi)+"<br><br>"+getString(R.string.mailText)+getTextToSendViaMail();
                    Uri pngUri = null;
                    File currentShopImage = new File(Environment.getExternalStorageDirectory().toString()+"/OpenGuide/"+Integer.toString(keyId)+"_1_normal.pn_");

                    if(currentShopImage.exists()){

                        File pngFile = new File(currentShopImage.toString());
                        pngUri = Uri.fromFile(pngFile);
                    }

                    Intent i = new Intent(Intent.ACTION_SEND);
                    i.setType("text/plain");
                    //i.putExtra(Intent.EXTRA_EMAIL, new String[] { emailCim });
                    i.putExtra(Intent.EXTRA_SUBJECT, "OpenGuide");
                    i.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(textToSend));
                    if(pngUri!= null)
                    i.putExtra(Intent.EXTRA_STREAM, pngUri);
                    try {
                        startActivity(Intent.createChooser(i, getString(R.string.SendMail)));
                    } catch (android.content.ActivityNotFoundException ex) {
                        Toast.makeText(ShopActivity.this, getString(R.string.MailClientNotFound), Toast.LENGTH_SHORT).show();
                    }

我怎么能achive这样的事?

How can i achive such a thing ?

推荐答案

至于我明白你的问题,你要放置图像与其他文本邮件中。在电子邮件协议的话,它被称为一个内嵌附件。

As far as I understood your problem, you want to place the image inside the mail with other text. In the words of Email protocol it's called an INLINE Attachment.

您将无法使用意图要做到这一点为没有安装在设备上的电子邮件客户端支持创建HTML邮件。

You would not be able to do this with intents as none of the email clients installed on the device supports creating html messages.

如果它真的你的应用程序的核心部分,你应该考虑一个第三方API来做到这一点。其中一个这样的库是的JavaMail 。你将能够通过这个库发送HTML邮件,但将设立一定的时间。

If it's really a core part of your app, you should consider a third party api to do this. One of the such library is JavaMail. You would be able to send html messages through this library but will take some time in setting up.

下面是一个<一个href=\"http://stackoverflow.com/questions/5260654/embedding-images-into-html-email-with-java-mail/\">link可能给你一些提示,它是如何做。

Here's a link that may give you some hint, how it's done.

这篇关于如何通过电子邮件发送图片在Android中,previewed但不要执着..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆