diff --git a/mailparser/mailparser-tests.ts b/mailparser/mailparser-tests.ts index 51d562788..b7df9adb4 100644 --- a/mailparser/mailparser-tests.ts +++ b/mailparser/mailparser-tests.ts @@ -1,3 +1,5 @@ +/// + import mailparser_mod = require("mailparser"); import MailParser = mailparser_mod.MailParser; import ParsedMail = mailparser_mod.ParsedMail; @@ -12,25 +14,25 @@ mailparser.on("headers", function(headers){ }); mailparser.on("end", function(mail){ - mail; // object structure for parsed e-mail + mail; // object structure for parsed e-mail }); - + // Decode a simple e-mail // This example decodes an e-mail from a string - + var email = "From: 'Sender Name' \r\n"+ "To: 'Receiver Name' \r\n"+ "Subject: Hello world!\r\n"+ "\r\n"+ "How are you today?"; - // setup an event listener when the parsing finishes + // setup an event listener when the parsing finishes mailparser.on("end", function(mail_object){ - console.log("From:", mail_object.from); //[{address:'sender@example.com',name:'Sender Name'}] - console.log("Subject:", mail_object.subject); // Hello world! - console.log("Text body:", mail_object.text); // How are you today? + console.log("From:", mail_object.from); //[{address:'sender@example.com',name:'Sender Name'}] + console.log("Subject:", mail_object.subject); // Hello world! + console.log("Text body:", mail_object.text); // How are you today? }); - // send the email source to the parser + // send the email source to the parser mailparser.write(email); mailparser.end(); @@ -42,7 +44,7 @@ import fs = require("fs"); mailparser.on("end", function(mail_object){ console.log("Subject:", mail_object.subject); }); - + fs.createReadStream("email.eml").pipe(mailparser); @@ -63,7 +65,3 @@ mp.on("attachment", function(attachment, mail){ var output = fs.createWriteStream(attachment.generatedFileName); attachment.stream.pipe(output); }); - - - -