0

I'm trying to read messages from inbox by subject, but if i search with a string like this: "Pedido de adição de danos à viatura sfaf", it does not work.

const inbox = require('inbox');

const imap = inbox.createConnection(emailConfig.imapPort, emailConfig.imapHost, { secureConnection: true, auth: emailConfig.auth })
  .
  .
  .
return new Promise<number[]>((resolve, reject) => {
    imap.search({ unseen: true, header: ["subject", subject] }, true, (err: any, uids: number[]) => {
        if (err) return reject(err);
        resolve(uids);
    })
});

When i run with that subject i get this error: "Error searching messages"

I'm reading from a Gmail account. Thanks in advance.

[EDIT: I do the connect and openMailBox before]

Franmcod
  • 319
  • 4
  • 12
  • What is `imap`? – Jordan Running Dec 07 '17 at 20:04
  • If you're using node-imap, a quick perusal of the documentation seems to indicate it doesn't actually support character set coding of search, thus, can only search ascii with compliant servers. I also don't see any ability to enable UTF-8 extensions if the server supports it. – Max Dec 07 '17 at 20:11
  • i'm using inbox. But gmail does nto support it? – Franmcod Dec 07 '17 at 20:14
  • Gmail supports it. Node.js is the limitation here. – arnt Dec 08 '17 at 10:51
  • @arnt Is there a way to get the encoding correct? – Franmcod Dec 08 '17 at 14:18
  • Node.js is open source, so yes, there is. You want node-imap to be able to send either ```ENABLE UTF8=ACCEPT``` early and later the regular search if the server advertises support for UTF8=ACCEPT, or ```SEARCH CHARSET UTF8 "sadfasdfasd"``` instead of just ```SEARCH "asdfsdf"``` if it does not. – arnt Dec 08 '17 at 15:46

0 Answers0