Question

1
Replies
405
Views
DEVIPRIYAV Member since 2012 1 post
Areteans
Posted: 2 years ago
Last activity: 2 years 9 months ago
Closed

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.

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)"

Error Message
When using the java code facing the below error:
"The method encodeToString(byte[]) in the type Base64Util is not applicable for the arguments (byte[], boolean)"
Low-Code App Development Data Integration Java and Activities
Moderation Team has archived post
Share this page LinkedIn