amethystct
Programmer
I have a delivery sheet being emailed. The first page is dynamic. That attaches fine. The second page has to be emailed with the first page also an attachment. They're both pdf files. When I try to attach it I get no errors but it creates an empty file. I don't want to recreate the second file, I just want to attach it.
Do I need to loop through the second file and attach it the same way with another setContent and will that replace the first file with the second?
Message msg = MimeMessageUtils.createMessage();
MimeMultipart mp = new MimeMultipart();
MimeBodyPart text = new MimeBodyPart();
text.setDisposition(Part.INLINE);
text.setContent(pEmailBody, "text/plain");
mp.addBodyPart(text);
String attachmentName = null;
MimeBodyPart file_part = null;
for (int ctr = 0; ctr < attachments.length; ctr++) {
file_part = new MimeBodyPart(new InternetHeaders(), attachments[ctr].getAttachment());
System.out.println("Size of attachment is: " + attachments[ctr].getAttachment().length);
file_part.setDisposition(Part.ATTACHMENT);
file_part.setHeader("Content-Transfer-Encoding", contentEncoding);
attachmentName = attachments[ctr].getFileName();
if (attachmentName != null) {
file_part.setFileName(attachmentName);
file_part.setDescription(attachmentName);
}
mp.addBodyPart(file_part);
}
msg.setContent(mp);
Do I need to loop through the second file and attach it the same way with another setContent and will that replace the first file with the second?
Message msg = MimeMessageUtils.createMessage();
MimeMultipart mp = new MimeMultipart();
MimeBodyPart text = new MimeBodyPart();
text.setDisposition(Part.INLINE);
text.setContent(pEmailBody, "text/plain");
mp.addBodyPart(text);
String attachmentName = null;
MimeBodyPart file_part = null;
for (int ctr = 0; ctr < attachments.length; ctr++) {
file_part = new MimeBodyPart(new InternetHeaders(), attachments[ctr].getAttachment());
System.out.println("Size of attachment is: " + attachments[ctr].getAttachment().length);
file_part.setDisposition(Part.ATTACHMENT);
file_part.setHeader("Content-Transfer-Encoding", contentEncoding);
attachmentName = attachments[ctr].getFileName();
if (attachmentName != null) {
file_part.setFileName(attachmentName);
file_part.setDescription(attachmentName);
}
mp.addBodyPart(file_part);
}
msg.setContent(mp);