on 06-04-2007 5:18 PM
Hi,
I wrote a Adapter Module to create attachment in Receiver Mail Adapter. I create a PDF document using the IText API and create the attachment using this one. But it not work properly and the attachment is not send with the e-mail. My code is:
public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData)
throws ModuleException{
try{
Document doc = new Document(PageSize.A4);
ByteArrayOutputStream out = new ByteArrayOutputStream();
PdfWriter.getInstance(doc,out);
doc.open();
PdfPTable table = new PdfPTable(3);
PdfPCell cell;
cell = new PdfPCell(new Paragraph("Rank"));
cell.setBackgroundColor(new Color(34, 90, 141));
table.addCell(cell);
cell = new PdfPCell(new Paragraph("Name"));
cell.setBackgroundColor(new Color(34, 90, 141));
table.addCell(cell);
cell = new PdfPCell(new Paragraph("Points"));
cell.setBackgroundColor(new Color(34, 90, 141));
table.addCell(cell);
//add the data rows.
int flag = 0;
Color bg;
for (int i = 0; i <= 10; i++){
//alternate colors
if (flag == 0){
flag = 1;
bg = new Color(204, 204, 255);
} else {
flag = 0;
bg = new Color(255, 255, 255);
}
cell = new PdfPCell(new Paragraph("1"));
cell.setBackgroundColor(bg);
table.addCell(cell);
cell = new PdfPCell(new Paragraph("Prakash Singh: " + i));
cell.setBackgroundColor(bg);
table.addCell(cell);
cell = new PdfPCell(new Paragraph("" + (50000 - i * 10) + ""));
cell.setBackgroundColor(bg);
table.addCell(cell);
}
doc.add(table);
doc.close();
Message msg = (Message)inputModuleData.getPrincipalData();
AuditMessageKey amk = new AuditMessageKey(msg.getMessageId(),AuditDirection.INBOUND);
Audit.addAuditLogEntry(amk,AuditLogStatus.SUCCESS,"CreateAttachment: Module Called");
Payload attachment = msg.createPayload();
attachment.setName("Order");
attachment.setContentType("Plain/Text");
attachment.setContent(out.toByteArray());
msg.addAttachment(attachment);
inputModuleData.setPrincipalData(msg);
}catch (Exception ex){
ModuleException me = new ModuleException(ex);
throw me;
}
return inputModuleData;
}
somebody has some ideia.
thanks.
Hi,
In the Module which u have developed set the content type to "application/pdf". It will change the content type.
With Regards
K.Varadharajan
Award points if it is usefull
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks. I set the contentType with Application/pdf and it work fine.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I checked the "Keep Attachments" in the Communication Channel and the file was sent, but the extension of attachment is .bin. How I do to change the extension file name in attachment to .pdf? And how I do to keep the content in body of the mail when the keep attachments is checked?
thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hey
u can use the File to mail(bypass scenario) for this.
don't do anything in IR,just do the configuration in ID and send the mail.
have a look at the following for bypass scenario
/people/william.li/blog/2006/09/08/how-to-send-any-data-even-binary-through-xi-without-using-the-integration-repository
thanx
ahamd
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
24 | |
11 | |
9 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.