diff --git a/lib/imap.js b/lib/imap.js index eddcebe..63b8eaa 100644 --- a/lib/imap.js +++ b/lib/imap.js @@ -925,7 +925,7 @@ ImapConnection.prototype._fetch = function(which, uids, options, what, cb) { uids = [uids]; utils.validateUIDList(uids); - var toFetch = '', prefix, extensions, self = this, + var toFetch = '', prefix = ' BODY[', extensions, self = this, parse = true, headers, key, stream, fetchers = {}; @@ -934,9 +934,9 @@ ImapConnection.prototype._fetch = function(which, uids, options, what, cb) { what = options; options = {}; } - prefix = (options.markSeen ? ' BODY.PEEK[' : ' BODY['); if (!Array.isArray(what)) what = [what]; + for (var i = 0, wp, pprefix, len = what.length; i < len; ++i) { wp = what[i]; if (wp.id !== undefined && !/^(?:[\d]+[\.]{0,1})*[\d]+$/.test(''+wp.id)) @@ -1117,8 +1117,12 @@ ImapConnection.prototype._fetch = function(which, uids, options, what, cb) { cmd += ' BODYSTRUCTURE'; if (options.size) cmd += ' RFC822.SIZE'; - if (toFetch) - cmd += toFetch; + if (toFetch) { + if (!options.markSeen) + cmd += toFetch.replace(/BODY\[/g, 'BODY.PEEK['); + else + cmd += toFetch; + } cmd += ')'; this._send(cmd, function(err) {