diff --git a/web/root/msgs/msgs.ssjs b/web/root/msgs/msgs.ssjs
index 1bb6d46b1dc7492085ad21f2d7a15918f29f9840..a4e9ee0cd08d8acc47b70da0a78472610c5b66c2 100644
--- a/web/root/msgs/msgs.ssjs
+++ b/web/root/msgs/msgs.ssjs
@@ -157,7 +157,7 @@ for(displayed=0;displayed<max_messages && last_offset >= 0;last_offset--) {
 	if(hdr==null)
 		continue;
 	template.messages[displayed.toString()]=hdr;
-	template.messages[displayed.toString()].attachments=count_attachments(msgarray[last_offset].hdr,msgbase.get_msg_body(true,msgarray[last_offset].offset));
+	template.messages[displayed.toString()].attachments=count_attachments(hdr,msgbase.get_msg_body(true,msgarray[last_offset].offset));
 	template.messages[displayed.toString()].offset=msgarray[last_offset].offset;
 	displayed++;
 }