sendgrid / sendgrid-nodejs

The Official Twilio SendGrid Led, Community Driven Node.js API Library
https://sendgrid.com
MIT License
3k stars 782 forks source link

Sending a reply with original email content quoted below #1277

Closed SKempin closed 3 years ago

SKempin commented 3 years ago

Issue Summary

I'm trying to send a reply as a thread, where the original email content is quoted below the reply content (as a standard email reply has).

Following https://github.com/sendgrid/sendgrid-nodejs/issues/482#issuecomment-641747083 and https://github.com/sendgrid/sendgrid-nodejs/issues/690#issuecomment-393336215 I have been able to create reply (which is successfully grouped as a thread) but the reply email itself doesn't include the previous email content as quoted content.

As there is a lack of documentation for replying in general I am unsure how to achieve this?

Steps to Reproduce

  1. Use Inbound Parse to post RAW message content to API endpoint
  2. Use simpleParser to parse email content
  3. Send reply as snippet below
  4. Reply is received but doesn't include the original email content as quoted content.

Code Snippet

  const parsedEmail = await simpleParser(req.body.email);
  const msg = {
    to: parsedEmail.from?.text,
    headers: {
      References: `${parsedEmail.references} ${parsedEmail.messageId}`,
      'In-Reply-To': parsedEmail.messageId,
    },
    from: 'myemail@mydomain.co.uk', // actual email removed for the purposes of this snippet
    subject: `Re: ${parsedEmail.subject}`, // where subject is the sender's subject.
    text: 'This is the reply from SendGrid',
  };

Technical details:

thinkingserious commented 3 years ago

Hello @SKempin,

Thanks for submitting a GitHub issue! We are very sorry that you are running into this problem. In order to better serve you, as this does not present itself as a library specific issue, we would like to ask that you reach out to our support team at https://support.sendgrid.com.

Thank you!

SendGrid DX Team

SKempin commented 3 years ago

@thinkingserious I submitted this as an issue but the team was unable to support. Is this not possible to achieve?

SKempin commented 3 years ago

For anyone looking for this behaviour I was able to emulate the formatting by wrapping the content in block quotes:

<blockquote type="cite">
    On ${datestamp}, at ${timestamp}, ${from} wrote:
    <br /><br />
    <div>${originalEmailContent}</div>
  </blockquote>