Results 1 to 8 of 8
  1. #1
    Zeus is offline Member
    Join Date
    Jun 2010
    Posts
    18
    Rep Power
    0

    Default Attachment File In Mail(Unknown Format)

    Hi, In my program, using java, i am not able to get the attachment files in the same format (.jpeg,....etc,) as i send through mail.some time i am able to get, some time i get in unknown format.

    Any idea to fix this or any new code regarding this...
    Below is the Attachment Code Part.

    Java Code:
    MimeBodyPart attachmentPart = new MimeBodyPart();
    DataSource source = new FileDataSource(filename[i]);
    filedisplayname = filename[i].substring(filename[i].lastIndexOf("/")+1);
    attachmentPart.setDataHandler(new DataHandler(source));
    attachmentPart.setFileName(filedisplayname);
    multipart.addBodyPart(attachmentPart);

    {i am trying to attach mutiple Files in a mail.}

  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 to validate the content type.

    Java Code:
    MimeBodyPart attachmentPart = (MimeBodyPart)part; // Main body part
    if (attachmentPart .isMimeType("text/plain")) {
       // Plain text
    } else {
        EMailAttach ema = new EMailAttach();
        ema.name = decodeName(part.getFileName());
        File savedir = new File([receiving_attachments]);
        // Make sure path exist
        File savefile = File.createTempFile("emailattach", ".atch", savedir );
        // Save the path accordingly
    }

  3. #3
    Zeus is offline Member
    Join Date
    Jun 2010
    Posts
    18
    Rep Power
    0

    Default

    actually the attached file is opening in gmail bt in yahoo it is of unknown format. can any one guess what may b the reason.

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

  5. #5
    Zeus is offline Member
    Join Date
    Jun 2010
    Posts
    18
    Rep Power
    0

    Default

    The file extention is the same as we give but in most mail servers i could not get that in rite format. Can any one give me another set of code which u may b using to attach files.

  6. #6
    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

    What you mean but not get the right format? Is it different from what you've attach and you downloaded from the other end?

  7. #7
    Zeus is offline Member
    Join Date
    Jun 2010
    Posts
    18
    Rep Power
    0

    Default

    Ya...Some unknown Format that v cant read

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

Similar Threads

  1. JavaMail - Problem while sending file attachment
    By saniruddhabiswas in forum Networking
    Replies: 0
    Last Post: 06-13-2010, 11:16 AM
  2. Deleting an attachment after sending mail
    By modestmj in forum Java Servlet
    Replies: 2
    Last Post: 06-02-2010, 11:52 AM
  3. Mail Attachment as Source
    By vinoopraj in forum Advanced Java
    Replies: 2
    Last Post: 06-15-2009, 06:21 AM
  4. Send / Receive mail and download attachment
    By Thennarasu in forum Advanced Java
    Replies: 1
    Last Post: 05-29-2009, 11:59 PM
  5. kindly answer the queston in attachment file
    By abhinav_jain09 in forum Advanced Java
    Replies: 11
    Last Post: 09-19-2008, 04:47 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
  •