当前位置: 动力学知识库 > 问答 > 编程问答 >

java - How do I attach file(image, audio, text) in mail application of android

问题描述:

I am trying to attach file in my mail app. but all time only body has been sent.I am using method:

 public void addAttachment(String path) throws Exception

{

BodyPart messageBodyPart = new MimeBodyPart();

DataSource dataSource = new FileDataSource(path);

messageBodyPart.setDataHandler(new DataHandler(dataSource));

messageBodyPart.setFileName(path);

Multipart multipart = new MimeMultipart();

multipart.addBodyPart(messageBodyPart);

}

I have used two jar file mail.jar, activation.jar. mail body is working fine. but attachment is not reached. please help me.

Thanks in andvance.

网友答案:

Your method looks the exact same as what I use and works.

But what I want to know is how you're calling the method?

message.addAttachment("./sdcard/img.jpg);

Or something like that?

分享给朋友:
您可能感兴趣的文章:
随机阅读: