Pega Email Bot : requirements
Requirement:
1.Pega Personnel Edition
Â
Activity ScreenShot:
Java Code in Step 6:
Â
java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
org.apache.commons.compress.archivers.ArchiveOutputStream logical_zip = null;
try{
logical_zip = new org.apache.commons.compress.archivers.ArchiveStreamFactory().createArchiveOutputStream(“zip”, baos);
} catch(Exception e) {
throw new PRRuntimeException(“Cannot initialize archive”);
}
Â
Â
ClipboardProperty cpResults = tools.findPage(“FileAttachmentsPage”).getProperty(“pxResults”);
int i = 1;
for (Iterator instPgList = cpResults.iterator(); instPgList.hasNext();) {
Â
Â
ClipboardProperty objOneRow = (ClipboardProperty) instPgList.next();
ClipboardPage objOneRowPage = objOneRow.getPageValue();
oLog.infoForced(“FileName Page: “+ objOneRowPage );
Â
Â
String strOutputPRFileName = objOneRowPage.getProperty(“pyAttachStream”).getStringValue();
byte [] data = Base64Util.decodeToByteArray(strOutputPRFileName);
oLog.info(data);
Â
String strOutputFileName = objOneRowPage.getProperty(“pxAttachName”).getStringValue();
Â
Â
oLog.infoForced(“File Stream: “+ strOutputPRFileName);
 PRFile prDestinationFile = new PRFile(strOutputPRFileName);
Â
Â
PRInputStream prOut = null;
Â
try {
    java.util.zip.ZipEntry entry = new java.util.zip.ZipEntry(strOutputFileName);
 logical_zip.putArchiveEntry(new org.apache.commons.compress.archivers.zip.ZipArchiveEntry(strOutputFileName));
 logical_zip.write(data);
    logical_zip.closeArchiveEntry();
   } catch(Exception e) {
    throw new PRRuntimeException(“Cannot create archive”);
  }
 i++;
}
//Send file to client
String s = tools.getLocalizedTextForString(“pyCaption”,”CaseAttachments”);
HashStringMap aMap = new HashStringMap();
aMap.put(“ContentDisposition”, “attachment; filename=”+s);
aMap.put(“ContentType”, “application/zip”);
try{
 logical_zip.finish();
 baos.close();
 String strFileData = Base64Util.encodeToString(baos.toByteArray());
 ClipboardPage myPage = tools.findPage(“FileAttachmentsPage”);
 myPage.getProperty(“SteamAttach”).setValue(strFileData);
 tools.sendFile(baos.toByteArray(),s+”.zip”,false,null,true);
 Â
} catch(Exception e) {
 throw new PRRuntimeException(“Error while sending:”+e.getMessage());
}
please let me know if you are unable to implement or need help, you can comment below or connect/contact me in linkedin : https://www.linkedin.com/in/bibhash-kalita-b477aa9b/
Hi bhinhash,
I need your inputs regarding downloading case attachments. Tried the above but facing errors
hi sinhaa umar,
please connect via linkein