开发者

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);
        开发者_如何学GomessageBodyPart.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.


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜