title: Spring Integration IMAP : Failed to read attachment from mail due to virus scanning in Outlook 365
body: <p>I am using Spring Integration to read email from Outlook 365 (cloud) using IMAP <code>inbound-channel-adapter</code>.</p>
  <p><strong>Scenario:</strong>
  Target mailbox in Outlook 365 is doing <strong>virus scanning for new emails</strong> once arrived, during this scan outlook is <strong>detaching the attachment</strong> and attaching it again once virus scan is completed.</p>
  <p><strong>Problem:</strong>
  Attachment is missing in very few cases (1 mail out of 50 approx), this is because of those emails are read by <code>inbound-channel-adapter</code> when the attachment is <strong>not</strong> available in outlook ( detached by virus scanner).</p>
  <p><strong>Question:</strong></p>
  <p>How can ensure the attachment was read every time? If I make the thread waiting for 2 mins inside <code>handleMessage</code> method, then <strong>will it block</strong> the reading of next email just arrived?
  OR please let me know any other solution to handle this situation.</p>
  <p><strong>Spring-integration.xml:</strong></p>
  <pre><code>&lt;util:properties id=&quot;javaMailProperties&quot;&gt;
      &lt;prop key=&quot;mail.imap.socketFactory.class&quot;&gt;javax.net.ssl.SSLSocketFactory&lt;/prop&gt;
      &lt;prop key=&quot;mail.imap.socketFactory.fallback&quot;&gt;false&lt;/prop&gt;
      &lt;prop key=&quot;mail.store.protocol&quot;&gt;imaps&lt;/prop&gt;
      &lt;prop key=&quot;mail.debug&quot;&gt;${imap.debug}&lt;/prop&gt;
      &lt;prop key=&quot;mail.imaps.partialfetch&quot;&gt;false&lt;/prop&gt;
      &lt;prop key=&quot;mail.imaps.fetchsize&quot;&gt;102400&lt;/prop&gt;   &lt;!-- 100KB, default is 16KB --&gt;  
  &lt;/util:properties&gt;
  
  &lt;mail:inbound-channel-adapter id=&quot;imapAdapter&quot; 
                                    store-uri=&quot;${imap.uri}&quot;                                     
                                    channel=&quot;recieveEmailChannel&quot;                                          
                                    should-delete-messages=&quot;false&quot;
                                    should-mark-messages-as-read=&quot;true&quot;                                      
                                    auto-startup=&quot;true&quot;
                                    simple-content=&quot;true&quot;
                                    auto-close-folder=&quot;true&quot;
                                    java-mail-properties=&quot;javaMailProperties&quot;&gt;
      &lt;int:poller fixed-delay=&quot;${imap.polling.interval}&quot; time-unit=&quot;SECONDS&quot;/&gt;
  &lt;/mail:inbound-channel-adapter&gt;
  
  &lt;int:channel id=&quot;recieveEmailChannel&quot;&gt;        
      &lt;int:interceptors&gt;
          &lt;int:wire-tap channel=&quot;logger&quot;/&gt;
      &lt;/int:interceptors&gt;
  &lt;/int:channel&gt;
  
  &lt;int:logging-channel-adapter id=&quot;logger&quot; level=&quot;DEBUG&quot;/&gt;
  
  &lt;int:service-activator input-channel=&quot;recieveEmailChannel&quot; ref=&quot;emailReceiver&quot; method=&quot;handleMessage&quot;/&gt;
  </code></pre>