Can I use the Gmail API to get the MD5 hash value for an attachment?

1.3k Views Asked by At

I work in an email security software company and we are currently faced with the question of being able to identify attachments in emails. Since we are cloud hosted, we need to be able to do this with Gmail and Outlook. It looks like the Outlook API will give you an atttachment hash under ContentBytes, but Gmail looks very limited in the attachment data it gives back to you.

Is there something I'm missing here?

1

There are 1 best solutions below

1
On

Attachments in emails are classified as content types in email.

Which you want to do is pull the content types off the emails

Emails with attachments usually have more than 1 content type associated to it.

Take a look at this RFC: https://www.ietf.org/rfc/rfc2045.txt

In an email I had, I looked at the RAW Text of one that had a PDF attachment and seen this content type.

Content-Type: application/pdf;

Then one that had an image attached to it.

Content-Type: image/jpeg;

You wouldn't need a special API to read this, just get the raw text of the message and parse it out.