I had a spot of trouble getting this to work, the root of the problem
is the path to the file you attach.

My solution is:

String dir    =   root.getAbsolutePath();

emailIntent.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file://"+dir+"/"+csvFname));

hope this helps,
Fred

On 02/08/2011, aparna rani <indela....@gmail.com> wrote:
> hii i am implement the one gmail function for sending file
> public void addAttachment(String filename) throws Exception {
>        BodyPart messageBodyPart = new MimeBodyPart();
>           DataSource source = new FileDataSource(filename);
>           messageBodyPart.setDataHandler(new DataHandler(source));
>           messageBodyPart.setFileName(filename);
>           _multipart.addBodyPart(messageBodyPart);
>
>           BodyPart messageBodyPart2 = new MimeBodyPart();
>           messageBodyPart2.setText(subject);
>
>           _multipart.addBodyPart(messageBodyPart2);
>       }
> public synchronized void sendMail(String subject, String body, String
> sender, String recipients) throws Exception {
>         try{
>         MimeMessage message = new MimeMessage(session);
>         DataHandler handler = new DataHandler(new
> ByteArrayDataSource(body.getBytes(), "text/csv"));
>         addAttachment("/sdcard/BarcodeScanner/Purchase/indela.csv");
>         message.setSender(new InternetAddress(sender));
>         message.setSubject(subject);
>         message.setContent(_multipart);
>         message.setDataHandler(handler);
>         message.setContent(_multipart);
>         if (recipients.indexOf(',') > 0)
>             message.setRecipients(Message.RecipientType.TO,
> InternetAddress.parse(recipients));
>         else
>             message.setRecipient(Message.RecipientType.TO, new
> InternetAddress(recipients));
>         Transport.send(message);
>         }catch(Exception e){
>
>         }
>     }
>
> with out attachment its working fine.
> with attachment it take file. that file name is "noname".
> in side file content is "this is body"
> please help me what is wrong in my project.
> this project i am testing in samsung galaxy fit s5670.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to