Results 1 to 3 of 3
  1. #1
    Malathi is offline Member
    Join Date
    Mar 2009
    Posts
    9
    Rep Power
    0

    Default Attachments were missing when mail was sent through java mail API

    Dear Experts,

    Our web application is based on struts and we are using java mail API to send mails to USA clients through our application.The problem is, they could able to receive the mail but they coudn't able to receive the attachments.

    Could you please let me know the problem behind that ASAP

    Regards,
    Malathi

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Better you should provide more details. How did you do that, and what happen(any observations) when you receive a mail with an attachment? And such details much helpful to others, commenting on.

  3. #3
    Malathi is offline Member
    Join Date
    Mar 2009
    Posts
    9
    Rep Power
    0

    Default

    Properties props = System.getProperties();
    props.put("mail.smtp.host", "10.0.1.6");
    Session session1 = Session.getDefaultInstance(props, null);
    MimeMultipart multipart = new MimeMultipart("related");
    MimeMessage message = new MimeMessage(session1);
    message.setFrom(new InternetAddress(mailFromAddress));
    message.setSubject(mailSubject);
    MimeBodyPart messageBodyPart1 = new MimeBodyPart();
    messageBodyPart1.setContent(mailContent, "text/html");
    multipart.addBodyPart(messageBodyPart1);

    FileDataSource fds1 = new FileDataSource(pdfFilePath);
    MimeBodyPart messageBodyPart2 = new MimeBodyPart();
    messageBodyPart2.setDataHandler(new DataHandler(fds1));
    messageBodyPart2.setFileName(fds1.getName());
    multipart.addBodyPart(messageBodyPart2);
    message.setContent(multipart);
    message.addRecipient(Message.RecipientType.TO,new InternetAddress("malathi@gmail.com"));
    message.addRecipient(Message.RecipientType.CC,new InternetAddress(maatharasi@gmail.com));
    Transport.send(message);

    it is sending for few users the mail with attachments correctly but for few users, it is sending the mail but it is missing the attachments.

    let me know if anybody is knowing the solution ASAP because the application is running in live server

Similar Threads

  1. Java Mail sending
    By jazz2k8 in forum Advanced Java
    Replies: 1
    Last Post: 05-01-2011, 06:08 AM
  2. Replies: 2
    Last Post: 05-05-2008, 06:01 AM
  3. Retreiving of mail body using mail number
    By chandu.v09 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 03-13-2008, 02:25 PM
  4. Send a pic through mail, in java
    By lenny in forum Advanced Java
    Replies: 1
    Last Post: 07-25-2007, 02:49 PM
  5. Sending a mail with the local mail program
    By thedude in forum Advanced Java
    Replies: 2
    Last Post: 07-23-2007, 12:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •