NEWS
imap Script - Anhänge speichern, wie ?
-
Hallo,
es gibt ja hier dieses imap Script:schedule("*/1 * * * *", function (obj) { var MailListener = require("mail-listener2"); var mailListener = new MailListener({ username: "abc", // hier Email Adresse eintragen password: "xxx", // hier Passwort eintragen host: "imap.xxx.de", port: 993, // imap port tls: true, connTimeout: 10000, // Default by node-imap authTimeout: 5000, // Default by node-imap, debug: null, // Or your custom function with only one incoming argument. Default: null tlsOptions: { rejectUnauthorized: false }, mailbox: "INBOX", // mailbox to monitor searchFilter: ["UNSEEN"], // the search filter being used after an IDLE notification has been retrieved markSeen: true, // all fetched email willbe marked as seen and not fetched next time fetchUnreadOnStart: true, // use it only if you want to get all unread email on lib start. Default is `false`, mailParserOptions: {streamAttachments: true}, // options to be passed to mailParser lib. attachments: false, // download attachments as they are encountered to the project directory attachmentOptions: { directory: "attachments/" } // specify a download directory for attachments }); mailListener.start(); mailListener.on("server:connected", function(){console.log("imap_connected");}); mailListener.on("server:disconnected", function(){console.log("imap_disconnected");}); mailListener.on("error", function(err){console.log(err);}); mailListener.on("mail", function(mail, seqno, attributes){ log(mail.from[0].address); log(mail.from[0].name); log(mail.subject); log(mail.text); var mailobj = {val: { from: mail.from[0].name, topic: mail.subject, text: mail.text } }; setState("javascript.0.System.Email.Reception", mailobj); setState("javascript.0.System.Email.from_address", mail.from[0].address); setState("javascript.0.System.Email.from_name", mail.from[0].name); setState("javascript.0.System.Email.mail_subject", mail.subject); setState("javascript.0.System.Email.mail_text", mail.text); }); mailListener.on("attachment", function(attachment){console.log(attachment.path);}); setTimeout(function(){mailListener.stop();},20000); });
Ich möchte nun, wenn eine bestimmte Mail kommt den Anhang speichern.
Müsste doch irgendwie mit diesen beiden Zeilen gehen.attachments: false, // download attachments as they are encountered to the project directory attachmentOptions: { directory: "attachments/" } // specify a download directory for attachments
Nur wie ?
Hat jemand mal ne Idee für mich.
Danke.