diff --git a/include/class.thread.php b/include/class.thread.php
index 8d468d9595cd1bffb5563963c4545a2b85637cc2..4b369d404bc4c4d97f092703c91a9f62cf27e32d 100644
--- a/include/class.thread.php
+++ b/include/class.thread.php
@@ -1055,7 +1055,8 @@ Class ThreadEntry {
         //Emailed or API attachments
         if (isset($vars['attachments']) && $vars['attachments']) {
             foreach ($vars['attachments'] as &$a)
-                if (isset($a['cid']) && strpos($body, 'cid:'.$a['cid']) !== false)
+                if (isset($a['cid']) && $a['cid']
+                        && strpos($body, 'cid:'.$a['cid']) !== false)
                     $a['inline'] = true;
             unset($a);