Solved

API route to get raw source of message

  • 6 December 2022
  • 3 replies
  • 110 views

Badge +2

Hi there,

 

I'm building a mechanism to export all of the data we have for a client and I need to include emails in that export. I can get a list of relevant message IDs from our applications database and now I just need to retrieve the original, raw, form of that email from your API (the same as saving the text in "View source" on a message).

 

I've had a brief look at your API docs but didn't spot an option for this (without having to synthesise it)! Can you point me to how I can go about doing this?

 

Many thanks

icon

Best answer by Javier - Developer Relations 6 December 2022, 01:08

View original

3 replies

Userlevel 5
Badge +8

Calling GET /messages/:msg_id with an Accept: text/plain header will return the raw email. You can view the documentation for how to use this endpoint in our Get message topic.

 

--Jason

Badge +2

By default this endpoint seems to exclude attachments from the email text that is returned. I'd quite like the original email as sent over the wire, although I notice that when I do show original they also seem to do something weird with attachments these days (I'm fairly sure that this wasn't the case a couple of years ago).

 

Any suggestions or explanations gratefully received.

 

Thanks

Userlevel 5
Badge +8

We are not returning the attachments with the raw message, and our Support team has flagged this with our Product team.

 

In the meantime you can still access the full attachments from a message by calling GET /messages/:message_id with an Accept: application/json header. You will find an array of attachments on the Message, which you can download by hitting their respective attachment download links.

 

Reply