sendgrid/sendgrid-nodejs

Cannot add charset="utf-8" to ics calendar invites for outlook

athoma13 opened this issue · 1 comments

Issue Summary

From nodejs, I cannot send an .ics calendar invite attachment to Microsoft Outlook (works for gmail). Outlook reports 'not supported calendar message.ics'. When I try remedy by adding charset='utf-8' to the attachment type, SendGrid throws a bad request error : The attachment type cannot contain ';', or CRLF characters.

Steps to Reproduce

  1. Create a ics formatted calendar attachment
  2. Add charset='utf-8' to the type

Code Snippet

const calEvent = `BEGIN:VCALENDAR
VERSION:2.0
PRODID:testapp.com
BEGIN:VEVENT
UID:ZpDo55HdX5EygysF4WFp
DTSTAMP:20211025T032330Z
DTSTART:20211026T000000Z
DTEND:20211026T010000Z
SUMMARY:Test event
DESCRIPTION:Wish Sendgrid would fix this
LOCATION:14 Milton Road\, Milton QLD\, Australia
GEO:-27.4668123;153.0106353
ORGANIZER;CN=Bob:MAILTO:bob@hotmail.com
METHOD:REQUEST
TRANSP:OPAQUE
CLASS:PRIVATE
SEQUENCE:0
END:VEVENT
END:VCALENDAR`;

const attachment = {
        filename: 'invite.ics',
        content: Buffer.from(calEvent).toString('base64'),
        disposition: 'attachment',
        type: 'text/calendar;method=REQUEST', // works in gmail - reports not supported calendar message.ics in outlook.live.com
     // type: 'text/calendar;method=REQUEST;charset="utf-8"', // breaks SendGrid with a The attachment type cannot contain ';', or CRLF characters
}

Exception/Log

{
    "message": "Bad Request",
    "code": 400,
    "response": {
        "headers": {
            "server": "nginx",
            "date": "Tue, 26 Oct 2021 04:30:42 GMT",
            "content-type": "application/json",
            "content-length": "216",
            "connection": "close",
            "access-control-allow-origin": "https://sendgrid.api-docs.io",
            "access-control-allow-methods": "POST",
            "access-control-allow-headers": "Authorization, Content-Type, On-behalf-of, x-sg-elas-acl",
            "access-control-max-age": "600",
            "x-no-cors-reason": "https://sendgrid.com/docs/Classroom/Basics/API/cors.html",
            "strict-transport-security": "max-age=600; includeSubDomains"
        },
        "body": {
            "errors": [
                {
                    "message": "The attachment type cannot contain ';', or CRLF characters.",
                    "field": "attachments.0.type",
                    "help": "http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.attachments.type"
                }
            ]
        }
    }
}

Additional: The error message is misleading too, since type='text/calendar;method=REQUEST' doesn't cause an error even though it contains ';'

Technical details:

  • sendgrid-nodejs version: 7.4.4
  • node version: 14

Looks like this is a known issue. Closing as a duplicate of #697. Recommend adding your vote there so it can be prioritized better.