--- a/src/internfile/mh_mail.cpp
+++ b/src/internfile/mh_mail.cpp
@@ -176,6 +176,9 @@
     }
     m_idx++;
     m_havedoc = m_idx < (int)m_attachments.size();
+    if (!m_havedoc) {
+        m_reason = "Subdocument index too high";
+    }
     return res;
 }