Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change value key in content array from content to value #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mullwaden
Copy link

Recently had issues with this. Turns out sendgrid uses 'value' instead of 'content' in the content array to store values. In addition the require the content array to be a specific order (text, html, ...others). This fixes that.

Stumbled upon this issue while trying to make inline ical events for outlook.

Error from sendgrid:

  The content value must be a string at least one character in length.
    content.0.value
    http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.content.value
  The content value must be a string at least one character in length.
    content.1.value
    http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.content.value
  The content value must be a string at least one character in length.
    content.2.value
    http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.content.value

Some sendgrid documentation: https://github.com/sendgrid/sendgrid-nodejs/blob/master/docs/use-cases/manual-content.md

If some poor soul out there is fighting outlook, this is how i added the events to nodemailer + sendgrid:

    icalEvent: {
      // need to base64 encode for sendgrid to be happy
      content: Buffer.from(calendarEventString).toString("base64"),
      filename: "invite.ics",
      method,
      encoding: "base64",
    },
    alternatives: [
      {
        // ical-generator adds line breaks (correctly) to the attachment. But quoted-printable
        // encoding which is applied to the inline event adds its own line breaks. So we remove these
        // and let sendgrid do the work
        content: calendarEventString.replace(/(\r\n )/g, ""),
        contentType: `text/calendar; method=${method}`,
      },
    ],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant