Question

ASB
NZ
Last activity: 5 Dec 2017 9:33 EST
Cant able to send a email with an attachment in pega 6.1SP2
Hi ,
Facing technical challenge in adding attachments in email. Taking values from Data Base and creating CSV file. I have used SendEmailWithAllAttachments and SendEmailNotifications Activity to send a mail with an attachments which i have created. I can able to send a mail but i cant able to attach the file. This is BRE(Business rule Engine) Application. We are not using flows.
While using the above mentioned OOTB Methods getting error like:
Caught javax.mail.MessagingException, IOException while sending message.
Hi ,
Facing technical challenge in adding attachments in email. Taking values from Data Base and creating CSV file. I have used SendEmailWithAllAttachments and SendEmailNotifications Activity to send a mail with an attachments which i have created. I can able to send a mail but i cant able to attach the file. This is BRE(Business rule Engine) Application. We are not using flows.
While using the above mentioned OOTB Methods getting error like:
Caught javax.mail.MessagingException, IOException while sending message.
the above OOTB activities are not working. So i tried with the below java code:
java.io.FileInputStream fileInputStream = null;
java.io.File file = new java.io.File("CostValues.pyDescription"); // FileOpenPath .. file location
byte[] bFile = new byte[(int) file.length()];
long myFileLenghth = file.length();
try {
fileInputStream = new java.io.FileInputStream(file);
fileInputStream.read(bFile);
fileInputStream.close();
}catch(Exception e)
{
tools.getPrimaryPage().addMessage( e.getMessage() );
}
ClipboardPage page_EmbedAttachment = null,
page_AttachmentPage = tools.findPage("AttachmentPage");
String attachmentData = Base64Util.encodeToString(bFile, false);
ClipboardProperty prop_pyAttachment = null;
try {
prop_pyAttachment = page_AttachmentPage.getProperty(".pyAttachments(<append>)");
page_EmbedAttachment = prop_pyAttachment.getPageValue();
page_EmbedAttachment.putString(".pyData","attachmentData");
page_EmbedAttachment.putString(".pyName","Test.csv");
page_EmbedAttachment.putString(".pyDecode","true");
page_EmbedAttachment.putString(".pyRemoveXML","false");
} catch (Exception e) {
tools.getPrimaryPage().addMessage( e.getMessage() );
}
the above code also haven't worked. Getting the below error:
"The method encodeToString(byte[]) in the type Base64Util is not applicable for the arguments (byte[], boolean)"
"The method encodeToString(byte[]) in the type Base64Util is not applicable for the arguments (byte[], boolean)"