mscdex / node-imap

An IMAP client module for node.js.
MIT License
2.17k stars 383 forks source link

Exchange and Keywords #214

Closed numkem closed 11 years ago

numkem commented 11 years ago

Hello,

I've been looking at using keywords with exchange to help me tag messages once they are processed and I'm running into the issue where searching by either uid or sequence number doesn't work with keywords.

I get this output when setting debug mode on :

<== '* OK [UIDNEXT 382] The next unique identifier value\r\nA6 OK [READ-WRITE] SELECT completed.\r\n'

[parsing incoming] saw untagged OK

<== 'A6 OK [READ-WRITE] SELECT completed.\r\n'

[parsing incoming] saw tagged response

==> A7 UID SEARCH KEYWORD testword

<== 'A7 BAD Command Argument Error. 11\r\n'

I've also tried using [[ 'HEADER' 'KEYWORD' 'testword' ]] as the criteria and while it passes the checks and doesn't throw an error. I don't get any results.

I also tried playing with the actual command sent to Exchage (ex. quoting the argument in various ways) to no avail.

Changing the SEARCH KEYWORD command to SEARCH KEYWORDS makes exchange say this :

<== 'A7 BAD The specified message set is invalid.\r\n'

Which makes me think that Exchange knows what SEARCH KEYWORD means since it's not saying the same error. I've taken a look at the implementation documentation of IMAP for Exchange and it says not so clearly that it 'should' work.

Dumping the full headers of a message shows that the keywords are indeed in the headers as keywords.

Has anyone else ran into this issue or is this a known thing that doesn't work?

Thanks.

mscdex commented 11 years ago

I think you may want: [['HEADER', 'Keywords', 'testword']]

EDIT: Additionally, it seems Exchange's support for 'KEYWORD' searches is dismal. According to this document, the only "keyword" you can search for is one called "$MDNSent".

numkem commented 11 years ago

I tried that with every way of writting 'Keywords' and I get no results...

This is against Exchange 2010 and here is part of the header show the keywords with the show() function that is in the README.

date: [ 'Sat, 11 Dec 2010 01:27:17 -0500' ],
'message-id': [ '<201012110627.oBB6RHK0024962@localhost>' ],
keywords: [ 'testword' ],
'content-language': [ 'en-US' ],
mscdex commented 11 years ago

I don't know. If it's the same mailbox and there is no error being generated, then Exchange's IMAP implementation is just being wonky (no surprise there).

numkem commented 11 years ago

Definitly no surprises there... Why would it say that the arguement is bad tho? Is it because something isn't quoted right?

mscdex commented 11 years ago

If you're referring to the 'KEYWORD' search response, see my original comment.

numkem commented 11 years ago

I was, thank you for the documentation. It's really lame on their part but not surprising. I might just have to use it like that.

Thanks for your time.