0

I was wondering if anyone knew how to send an email with an image attached to it from Parse's Sendgrid module (by this, I mean Facebook's Parse BaaS, not SendGrid's Parse API). So far, I can send out emails, but not with an image attached to it. I tried two different things. One is sending the email as Base64, but I read that is not supported by A LOT of email providers, therefore I was discouraged in using this method since compatibility is kind of an issue here (not critical though). My second approach was to try to mimic sendgrid's process of using a cid, but maybe I was doing something wrong and it did not work

var sendGridInstance = require('sendgrid');
    sendGridInstance.initialize(sendGridUser, sendGridKey);
    sendGridInstance.sendEmail({
         to:endCustomerEmail,
         from: 'test@test.com',
         subject: 'Test subject',
         html: 'My HTML goes here..',
         replyto: 'donotreply@test.com'

The code above works whenever it is called in CloudCode, and indeed sends an email. But the cid thing does not work.

Has anyone successfully sent an email w/image using the sendgrid module with Parse? If so, could you please tell me what am I missing?

All help is much appreaciated!

Thank you!

Cheers!

idelara
  • 1,648
  • 4
  • 22
  • 44

1 Answers1

0

This module doesn't support binary files - it calls SendGrid API with application/x-www-form-urlencoded request and you can't urlencode contents of binary file. Take a look at https://github.com/m1gu3l/parse-sendgrid-mailer instead - it calls API with multipart/form-data request which is better suited for this case.

Community
  • 1
  • 1
m1gu3l
  • 774
  • 5
  • 18
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/10515357) – rajuGT Dec 10 '15 at 16:22
  • Well, it's a repo with module that supports binary files, I don't know what you expectected me to include. – m1gu3l Dec 10 '15 at 16:35