Results 1 to 3 of 3
  1. #1
    modestmj is offline Member
    Join Date
    Jun 2010
    Rep Power

    Default Deleting an attachment after sending mail

    Hello everyone..

    I'm trying to forward a PDF with a mail and also delete it from the tomcat/bin folder after sending it as it gets generated in that folder. But the problem is if I try to use the delete method, the file is deleted even before the mail is sent. So I was hoping if anyone could help me on this.

    Java Code:
     File[] pdfFile = {DownloadProfile.generateProfile(profileId, "pdf", request, response)};
                //Format Subject:
                String subject = ContentUtil.get("com/inikah/template/common-subject.txt");
        		subject = subject.replace("[$mail-context$]", "Please Check This Pdf");
        		subject = subject.replace("[$profile-name$]", profile.getProfileName());
        		subject = subject.replace("[$profile-code$]", profile.getProfileCode());
        		//Format Body:
        		String body = ContentUtil.get("com/inikah/template/profile/profile-attachment.html");
        		body = body.replace("[$contact-person$]", "Sr/Br");
        		body = body.replace("[$profile-name$]", profile.getProfileName());
        		body = body.replace("[$profile-code$]", profile.getProfileCode());
        		for (String toAddress: email) {
                    if (Validator.isNotNull(toAddress)) MailUtil.sendMail(toAddress, subject, body, pdfFile);

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

Similar Threads

  1. Replies: 1
    Last Post: 03-05-2010, 02:05 AM
  2. problem with sending mail usin javaX.mail api
    By sandeepsai39 in forum New To Java
    Replies: 4
    Last Post: 11-25-2009, 05:37 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. 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