I have a response coming from sendgrid inbound webhook, and it have some attachment, but is there any way we can separate the attachment from the full email payload.
This is the email body we receive from sendgrid below: I have shortened the email body and included important property including the X-Attachment-Id and right below is base64 attachment.
body = {
dkim: '{@gmail.com : pass}',
subject: 'Subject 1',
email: 'Received: by mx0121p1iad2.sendgrid.net with SMTP id U3SN4cHg8C Wed, 21 Sep
2022 16:36:45 +0000 (UTC)\n' +
'--000000000000de567405e9328c5d\n' +
'Content-Type: application/pdf; name="dummy copy.pdf"\n' +
'Content-Disposition: attachment; filename="dummy copy.pdf"\n' +
'Content-Transfer-Encoding: base64\n' +
'Content-ID: <f_l8buktdz0>\n' +
'X-Attachment-Id: f_l8buktdz0\n' +
'\n' +
'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp\n' +
'bHRlci9GbGF0ZURlY29kZT4+CnN0cmVhbQp4nD2OywoCMQxF9/mKu3YRk7bp\n' +
'tDAIDuh+oOAP+AAXgrOZ37etjmSTe3ISIljpDYGwwrKxRwrKGcsNlx1e31mt\n' +'\n' +
'--000000000000de567405e9328c5d\n' }
I know I can use string methods to separate the part below the X-Attachment-ID property for making the attachment which is in base64 format, but is there any other way from sendgrid so we can separate any number of attachments.