1 17 package org.apache.james.util.mail.mdn; 18 19 import javax.mail.MessagingException ; 20 import javax.mail.internet.MimeBodyPart ; 21 22 import org.apache.james.util.mail.MimeMultipartReport; 23 24 28 public class MDNFactory 29 { 30 31 34 private MDNFactory() 35 { 36 super(); 37 } 38 39 53 static public MimeMultipartReport create(String humanText, 54 String reporting_UA_name, 55 String reporting_UA_product, 56 String original_recipient, 57 String final_recipient, 58 String original_message_id, 59 Disposition disposition) throws MessagingException 60 { 61 MimeMultipartReport multiPart = new MimeMultipartReport(); 64 multiPart.setReportType("disposition-notification"); 65 66 MimeBodyPart humanPart = new MimeBodyPart (); 68 humanPart.setText(humanText); 69 multiPart.addBodyPart(humanPart); 70 71 StringBuffer mdnReport = new StringBuffer (128); 74 mdnReport.append("Reporting-UA: "); 75 mdnReport.append((reporting_UA_name == null ? "" : reporting_UA_name)); 76 mdnReport.append("; "); 77 mdnReport.append((reporting_UA_product == null ? "" : reporting_UA_product)); 78 mdnReport.append("\r\n"); 79 if (null != original_recipient) 81 { 82 mdnReport.append("Original-Recipient: "); 83 mdnReport.append("rfc822; "); 84 mdnReport.append(original_recipient); 85 mdnReport.append("\r\n"); 86 } 87 mdnReport.append("Final-Recepient: "); 89 mdnReport.append("rfc822; "); 90 mdnReport.append((final_recipient == null ? "" : final_recipient)); 91 mdnReport.append("\r\n"); 92 mdnReport.append("Original-Message-ID: "); 94 mdnReport.append((original_message_id == null ? "" : original_message_id)); 95 mdnReport.append("\r\n"); 96 mdnReport.append(disposition.toString()); 98 mdnReport.append("\r\n"); 99 MimeBodyPart mdnPart = new MimeBodyPart (); 100 mdnPart.setContent(mdnReport.toString(), "message/disposition-notification"); 101 multiPart.addBodyPart(mdnPart); 102 103 return multiPart; 110 } 111 112 } 113 | Popular Tags |