UNPKG

@independentsoft/msg

Version:

Outlook .msg file module

32 lines (26 loc) 1.13 kB
import * as msg from './../independentsoft/msg.js'; import * as fs from 'fs'; let recipient1 = new msg.Recipient(); recipient1.addressType = "SMTP"; recipient1.displayType = msg.DisplayType.MAIL_USER; recipient1.objectType = msg.ObjectType.MAIL_USER; recipient1.displayName = "John@domain.com"; recipient1.emailAddress = "John@domain.com"; recipient1.recipientType = msg.RecipientType.TO; let recipient2 = new msg.Recipient(); recipient2.addressType = "SMTP"; recipient2.displayType = msg.DisplayType.MAIL_USER; recipient2.objectType = msg.ObjectType.MAIL_USER; recipient2.displayName = "Mary@domain.com"; recipient2.emailAddress = "Mary@domain.com"; recipient2.recipientType = msg.RecipientType.CC; let message = new msg.Message(); message.subject = "Test"; message.body = "Body text"; message.displayTo = "John Smith"; message.displayCc = "Mary Smith"; message.recipients.push(recipient1); message.recipients.push(recipient2); message.messageFlags.push(msg.MessageFlag.UNSENT); message.storeSupportMasks.push(msg.StoreSupportMask.CREATE); fs.writeFileSync("e:\\message.msg", message.toBytes());