Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

79
Views
MIME Message, missing fields in mail

I have this function MIME message that I then POST to google draft API. When manually checking in my drafts, the mailContent show's up properly.

  const mailContent = req.body.content

  .
  .
  .


  var message = 'MIME-Version: 1.0\r\n' +
  'Content-type: multipart/alternative; boundary=boundaryboundary\r\n\r\n' +
  '--boundaryboundary\r\n' +
  'Content-type: text/plain; charset=UTF-8\r\n' +
  mailContent + "\r\n\r\n" +
  '--boundaryboundary--';

Now I'm trying to add the From, To and Subject fields in my MIME message, and after quite some research, I thought that adding them to the 'body' like so would do the trick:

  const mailContent = req.body.content
  const from = "exyleprod@gmail.com"
  const to = req.body.to || ""
  const subject = req.body.subject || ""
  .
  .
  .

  var message = 'MIME-Version: 1.0\r\n' +
  'Content-type: multipart/alternative; boundary=boundaryboundary\r\n\r\n' +
  'From: SomeName ' + '<' + from + '>' + "\r\n" +
  'To: ' + '<' + to + '>' + "\r\n" +
  'Subject: ' + subject + "\r\n" +
  '--boundaryboundary\r\n' +
  'Content-type: text/plain; charset=UTF-8\r\n' +
  mailContent + "\r\n\r\n" +
  '--boundaryboundary--';

But it doesn't... I've tried logging the added fields and they are what I expect. The POST still work's and successfully create's an other draft with the mailContent. However, the 3 fields I'm trying to add don't show up. An I doing this wrong ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try to do it this way:

var message = {
  from: "sender@example.com",
  to: "receiver@example.com",
  subject: "Message title",
  text: "Plaintext version of the message",
  html: "<p>HTML version of the message</p>"
};
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!