Мое требование - общий c PDF, мне нужно прикрепить stati c PDF для электронной почты, я могу прикрепить общий c PDF без каких-либо проблем, но это вызывает у меня проблему со статистикой c PDF при извлечении его из каталога, я попробовал несколько способов, не могли бы вы помочь ....
Ниже приведена ошибка и связанный с ней код ....
Error :java.io.FileNotFoundException: /mnt/DGB/Correspondence/Systems/PROD_DOCS/How_to_access_member_information.pdf (No such file or directory)
Код :
try {
File pdfFile = new File("//mnt/DGB/Correspondence/Systems/PROD_DOCS/How_to_access_member_information.pdf");
byte[] bytesArray = new byte[(int) pdfFile.length()];
FileInputStream fis = new FileInputStream(pdfFile);
fis.read(bytesArray); //read file into bytes[]
fis.close();
String registerId = notificationEngineService.registerFileOnNe("application/pdf", "How_to_access_member_information.pdf", bytesArray);
System.out.println("registerId 1=============================== " + registerId);
notificationEngineService.sendRegisteredAttViaNe(registerId, emailBody, dispInfo);
} catch (Exception e) {
System.out.println("Exception 10============================================================");
e.printStackTrace();
}
try {
File pdfFile = new File("\\\\dcpcifs01\\DGB\\Correspondence\\Systems\\PROD_DOCS\\How_to_access_member_information.pdf");
byte[] bytesArray = new byte[(int) pdfFile.length()];
FileInputStream fis = new FileInputStream(pdfFile);
fis.read(bytesArray); //read file into bytes[]
fis.close();
String registerId = notificationEngineService.registerFileOnNe("application/pdf", "How_to_access_member_information.pdf", bytesArray);
System.out.println("registerId 2=============================== " + registerId);
notificationEngineService.sendRegisteredAttViaNe(registerId, emailBody, dispInfo);
} catch (Exception e) {
System.out.println("Exception 10============================================================");
e.printStackTrace();
}
} catch (Exception ex) {
ex.printStackTrace();
throw new GroupRiskSystemException(ExceptionCode.COMPASS_ERROR.name());
}
return "";
}
private void sendEmail(MbsMembers memberObject) {
try {
System.out.println(" ======================Start0=================================== ");
za.co.discoverygrouprisk.common.jaxb.email.AttachmentType attachmentType = new za.co.discoverygrouprisk.common.jaxb.email.AttachmentType();
attachmentType.setMember(new MemberType());
attachmentType.setCamundaProcessId("0");
attachmentType.setFileName("How_to_access_member_information.pdf");
attachmentType.setChildBusinessKey(0l);
attachmentType.setNeID(0l);
DGRMultiAttachmentEmailDetailV01 emailDetail = new DGRMultiAttachmentEmailDetailV01();
SchemeDataType schemeDataType = new SchemeDataType();
SchemeType schemeType = new SchemeType();
SchemeNumberType schemeNumberType = new SchemeNumberType();
schemeNumberType.setValue(01);
schemeType.setSchemeNumber(schemeNumberType);
schemeDataType.setScheme(schemeType);
emailDetail.setSchemeData(schemeDataType);
EmailDataType emailDataType = new EmailDataType();
EmailType emailType = new EmailType();
emailType.setSubject("How to access member information");
emailType.setFromAddress("groupinfo@discovery.co.za");
emailType.setToAddress(memberObject.getEmailAddress());
emailDataType.setEmail(emailType);
emailDetail.setEmailData(emailDataType);
AttachmentDataType attachmentDataType = new AttachmentDataType();
// attachmentDataType.setLocation("//mnt/DGB/Correspondence/Systems/PROD_DOCS/");
attachmentDataType.setLocation("\\\\dcpcifs01\\DGB\\Correspondence\\Systems\\PROD_DOCS\\");
//mnt/DGB/Correspondence/2020/QA/MEMBER_REQUIREMENT_LETTER
attachmentDataType.setParentBusinessKey(01);
attachmentDataType.getAttachment().add(attachmentType);
emailDetail.setAttachmentData(attachmentDataType);
EmailDataSource adHocDS = new AdHocEmailDataSource(emailDetail);
String emailBody = createEmailBody(memberObject);
StandardEmailTemplate template = new StandardEmailTemplate(emailBody);
Email email = new StandardEmail(adHocDS, template);
email.createEmail();
email.sendEmail();
System.out.println(" ======================End0=================================== ");
} catch (Exception e) {
System.out.println(" ======================Exception0=================================== ");
e.printStackTrace();
}
}