papnkukn / eml-format

RFC 822 EML file format parser and builder
MIT License
84 stars 51 forks source link

Tag X-Unset in building eml #11

Closed egmen closed 4 years ago

egmen commented 5 years ago

I need tag X-Unsent: 1 in resulted eml file to edit email after opening in Outlook. Now I add it manually. Somebody can add this to module.

fvilers commented 5 years ago

In the web world, headers prefixed with X are custom headers. That's why the library doesn't support it out of the box. But if you want to generate an EML file with that header, you should add it to your data headers.

For example:

const data = {
      headers: {
        'X-Unsent': '1'
      },
      from: this.from,
      to: this.to,
      subject: this.subject,
      html: `<html>${this.message}</html>`
    };
emlformat.build(data, function(error, eml) { ... });
papnkukn commented 4 years ago

@fvilers thanks for providing the answers.

That is correct, each EML header is provided in the headers property while the standard and most used properties like from, to, subject are provided directly in the data object.