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

    Default Deleting an atatchment 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


    This post has been locked. OP: please avoid duplicate posts.

Similar Threads

  1. Java Mail sending
    By jazz2k8 in forum Advanced Java
    Replies: 1
    Last Post: 05-01-2011, 06:08 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. problem with sending mail usin javaX.mail api
    By sandeepsai39 in forum New To Java
    Replies: 4
    Last Post: 11-25-2009, 06:37 AM
  4. Sending a Mail
    By haiforhussain in forum Advanced Java
    Replies: 7
    Last Post: 07-30-2008, 12:28 AM
  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