2017-03-17 1 views
0

첨부 파일이 보낸 사람의 서명 이미지인지 식별하고 해당 첨부 파일을 건너 뛰고 싶을 때 무시해야하지만 식별 할 수 없습니다. 그 특별한 첨부는 서명 이미지입니다.Java EWS- 첨부 파일이 보낸 사람 서명 이미지인지 식별하는 방법

사용자가 서명 이미지를 추가하는 동안 사용자 지정 속성을 추가 할 수 있습니까? 그렇다면 프로그램에서 해당 속성을 찾을 수 있습니까?

if (emailMessage.getHasAttachments() || emailMessage.getAttachments().getItems().size() > 0) { 

//get all the attachments 
AttachmentCollection attachmentsCol = emailMessage.getAttachments(); 

log.info("File Count: " + attachmentsCol.getCount()); 

    Attachment attachment = attachmentsCol.getPropertyAtIndex(i); 
    //log.debug("Starting to process attachment "+ attachment.getName()); 

    //do we need to skip this attachment 

     FileAttachment fileAttachment = (FileAttachment) attachment; 
     // if we don't call this, the Content property may be null. 
     fileAttachment.load(); 
     booelan isSignatureImage = fileAttachment.isContactPhoto(); // this is false 
} 

은}

답변

0

나는이 작업을 수행 할 수있는 방법을 알아 냈어. 코드를 한 번 실행하고 무시할 첨부 파일의 해시를 결정한 다음이 해시의 로컬 문자열을 만듭니다. 그런 다음 처리하는 각 첨부 파일을이 로컬 해시 문자열과 비교하여 일치하는 경우 해당 첨부 파일을 무시하고 다음으로 이동합니다 (내가있는 것처럼 루프에서 첨부 파일을 처리하는 경우).

  // you must first load your attachment to be able to call .getContent() on it 
      fileAttachment.load(); 

      // load content 
      byte[] b = fileAttachment.getContent(); 

      // get the hash of your attachment 
      byte[] hash = MessageDigest.getInstance("MD5").digest(b); 

      // after you run this on the attachment you do not want, take the string from 'actual' below and put it here 
      String expected = "YOUR HASHED STRING"; 

      String actual = DatatypeConverter.printHexBinary(hash); 
      System.out.println(actual); 

      // some conditional to check if your current hash matches expected 
      if(actual.equals(expected)){ 
       continue; 
      } 
관련 문제