发送电​​子邮件与黑莓PDF附件 [英] sending email with pdf attachment in blackberry

查看:192
本文介绍了发送电​​子邮件与黑莓PDF附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要邮件服务在我的应用程序集成。我的应用程序应该发送电子邮件,其中有附加.pdf文件(详细报道)。 PDF文件现在是在远程服务器。

谁能帮助我了解如何与PDF格式的附件黑莓发送邮件?如果,这是贯彻落实可行的话我怎么会与此去?

下面是链接,我从黑莓知识库论坛得到了中黑莓发送邮件

<一个href=\"http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800698/How_To_-_Create_an_Attachment.html?nodeid=800544&vernum=0\"相对=nofollow>如何 - 创建

<一个href=\"http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800698/How_To_-_Create_and_send_messages.html?nodeid=1008283&vernum=0\"相对=nofollow>如何 - 创建和发送邮件


解决方案

我相信<一个href=\"http://docs.blackberry.com/en/developers/deliverables/11935/Send_msg_with_attachment_565471_11.jsp\"相对=nofollow>这是你的问题的第一个链接的更新版本。

在你的情况,你要发送的PDF文档,所以你将取代内容类型与应用程序/ PDF 和文件名可能是 DetailedReport.pdf ,或任何你喜欢。这名不是完整路径。只是,将由电子邮件的收件人可以看到一个名称。

  SupportedAttachmentPart附加=新SupportedAttachmentPart(多部分,
    应用程序/ PDF,DetailedReport.pdf,数据);

字节[] 是你必须自己阅读,打开本地PDF文件(无论你把它存储)的东西。这只是从文件的二进制数据,所以我会使用一个 DataInputStream以

 字符串fileUrl =文件:///SDCard/BlackBerry/SomePath/DetailedReport.pdf;
fileConn的FileConnection =(的FileConnection)Connector.open(fileUrl,Connector.READ);
INT档案大小= fileConn.fileSize();
字节[]数据=新的字节[档案大小]
DataInputStream以输入= fileConn.openDataInputStream();
input.read(数据);

当然,我建议做在后台线程这项工作,以避免冻结您的UI。

I need to integrate mail service in my application. My application should send the email, which has to attach a .pdf file (detailed report). PDF file is now at remote server.

Can anyone help me to understand how to send mail with pdf attachment in blackberry? If, it is feasible to implement then how would i go with this?

Below are the links, I have got from Blackberry knowledge base forum for sending mail in blackberry

How To - Create an attachment

How To - Create and send messages

解决方案

I believe this is the updated version of the first link in your question.

In your case, you want to send a PDF document, so you would replace the content-type with application/pdf, and the filename could be DetailedReport.pdf, or whatever you like. This filename is not a full path. Just a name that will be seen by the recipient of the email.

SupportedAttachmentPart attach = new SupportedAttachmentPart(multipart,
    "application/pdf", "DetailedReport.pdf", data);

The byte[] is something you have to read in yourself, opening the local pdf file (wherever you stored it). It's just the binary data from the file, so I'd use a DataInputStream:

String fileUrl = "file:///SDCard/BlackBerry/SomePath/DetailedReport.pdf";
FileConnection fileConn = (FileConnection)Connector.open(fileUrl, Connector.READ);
int fileSize = fileConn.fileSize();
byte[] data = new byte[fileSize];
DataInputStream input = fileConn.openDataInputStream();
input.read(data);

And of course, I would recommend doing this work on a background thread to avoid freezing your UI.

这篇关于发送电​​子邮件与黑莓PDF附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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