2015-01-26 6 views
0

Google 애플리케이션에서는 iMap을 사용하여 Gmail에서 이메일을 읽고 DB에 저장하고 있습니다. 이메일에는 첨부 파일이 두 개 있습니다 (하나는 pdf 파일이고 다른 하나는 디지털 서명 파일입니다). 첫 번째 파일 (pdf)의 경우 처리 null이되어 첨부 파일을 처리 할 수 ​​없지만 두 번째 파일 (p7)은 첨부 파일로 올바른 처리 값을 얻습니다.첨부 파일의 경우 imap 처리가 null입니다.

------=_NextPart_001_0025_01D03944.5B3A2140 
Content-Type: application/pdf; 
       name="USXMS III Draft PUS - VOPR # 15-814.pdf" 
Content-Transfer-Encoding: base64 
Content-Disposition: attachment; 
       filename="USXMS III Draft PUS - VOPR # 15-814.pdf" 


    ------=_NextPart_000_0024_01D03944.5B3A2140 
Content-Type: application/pkcs7-signature; name="smime.p7s" 
Content-Transfer-Encoding: base64 
Content-Disposition: attachment; filename="smime.p7s" 

다음은 이메일의 첨부 파일을 처리하는 관련 코드입니다 :

//Process attchements of email 
protected processAttachments(def workItem, def message) { 
    int attachmentCount = 0 
    def content = message.content 
    if (content instanceof Multipart) { 
     for (cntr in 0..(content.count - 1)) { 
      def bodyPart = content.getBodyPart(cntr) 
      def disposition = bodyPart.getDisposition() 
      println("Disposition is " + disposition + ".");// returns null for pdf 
      if (Part.ATTACHMENT.equalsIgnoreCase(disposition)) { 
       if (this.saveAttachments(workItem, bodyPart)) { 
        attachmentCount++ 
       } 
      } 
     } 
    } 
    return attachmentCount 
} 

그래서 위의 코드 getDisposition에 pdf 파일에 대한 null를 돌려 다음

첨부 파일의 헤더 정보입니다. 자세한 정보가 필요하면 알려주십시오.

+1

어떤 언어입니까? 어떤 도서관? 라이브러리가 다중 행 헤더를 제대로 처리하지 못하도록 할 수 있습니까? – Max

+0

나는 javax.mail을 사용하는 Grails를 사용하여 jericho를 사용하여 html 콘텐츠를 파싱합니다. 문제는 pdf 헤더 만 읽을 수없고 다른 첨부 파일도 문제가없는 이유입니다. – kmpsharma

+0

중첩 된 콘텐츠이므로 문제가 해결되었습니다. 처분이 null 인 경우 첨부 파일을 찾기 위해 내용을 반복해야합니다. – kmpsharma

답변

0

중첩 된 콘텐츠로 해결되었습니다. 처분이 null 인 경우 첨부 파일을 찾으려면 내용을 반복해야합니다.