Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. imap Script - Anhänge speichern, wie ?

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    imap Script - Anhänge speichern, wie ?

    This topic has been deleted. Only users with topic management privileges can see it.
    • bahnuhr
      bahnuhr Forum Testing Most Active last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post

      Support us

      ioBroker
      Community Adapters
      Donate

      779
      Online

      31.7k
      Users

      79.8k
      Topics

      1.3m
      Posts

      javascript
      1
      1
      85
      Loading More Posts
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes
      Reply
      • Reply as topic
      Log in to reply
      Community
      Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
      The ioBroker Community 2014-2023
      logo