constopenBox=require('imap-open-box') constimap=newImap({ user:'me@gmail.com', password:'abc123', host:'imap.gmail.com', port:993, tls:true }) imap.once('ready',()=>{ openBox({imap,box:'INBOX'}) .then(details=>{ //information about the box ...
imap.once('ready', () => { imap.openBox('INBOX', false, (err, box) => { if (err) throw err; // 在这里可以进行进一步的操作,如搜索特定的邮件、读取邮件内容等 }); }); 这里使用 imap.openBox 方法打开收件箱,你可以根据需求选择其他文件夹。 进行空闲通知的监听和处理: 代码语言:txt 复制...
{// 打开收件箱imap.openBox('INBOX',true,(error,mailbox)=>{if(error){console.log(error);return;}// 搜索邮件imap.search(['ALL'],(error,results)=>{if(error){console.log(error);return;}// 获取邮件列表constfetch=imap.fetch(results,{bodies:''});// 遍历邮件fetch.on('message',(...
log(prefix + 'Finished attachment %s', filename); }); }; } imap.once('ready', function() { imap.openBox('INBOX', true, function(err, box) { if (err) throw err; var f = imap.seq.fetch('1:3', { bodies: ['HEADER.FIELDS (FROM TO SUBJECT DATE)'], struct: true }); f....
imap.openBox('INBOX', true, cb); } imap.once('ready', function() { openInbox(function(err, box) { if (err) throw err; var f = imap.seq.fetch('1:3', { bodies: 'HEADER.FIELDS (FROM TO SUBJECT DATE)', struct: true }); f.on('message', function(msg, seqno) { console.log...
inspect; var imap = new Imap({ user: 'mygmailname@gmail.com', password: 'mygmailpassword', host: 'imap.gmail.com', port: 993, tls: true }); function openInbox(cb) { imap.openBox('INBOX', true, cb); } imap.once('ready', function() { openInbox(function(err, box) { if (...
openBox('INBOX', true, (err, box) => { if (err) throw err; console.log(`Opened INBOX - ${inspect(box)}`); imap.search(['ALL'], (err, results) => { if (err) throw err; const fetchOptions = { bodies: ['HEADER.FIELDS (FROM SUBJECT DATE)', 'TEXT'], struct: true...
inspect; var imap = new Imap({ user: 'mygmailname@gmail.com', password: 'mygmailpassword', host: 'imap.gmail.com', port: 993, tls: true }); function openInbox(cb) { imap.openBox('INBOX', true, cb); } imap.once('ready', function() { openInbox(function(err, box) { if (...
imap.openBox('INBOX',true,function(err,box){if(err)throw err; let f=imap.seq.fetch('1:1',{bodies:'HEADER.FIELDS(FROM TO SUBJECT DATE)',struct:true}); f.on('message',function(msg,seqno){console.log('Message#%d', seqno);});});}); ...
imap.openBox('INBOX',true, cb); }varmessages =[] imap.once('ready',function() { openInbox(function(err, box) { console.log("open")if(err)throwerr; imap.search(['UNSEEN', ['SINCE', 'May 20, 2010'] ],function(err, results) {if(err)throwerr;varf = imap.fetch(results, { bod...