I found the solution.
You must use the Email Parse function of Utility Functions for SOAR with the following entries:
inputs.incident_id = incident.id
inputs.attachment_id = attachment.id
inputs.utilities_parse_email_attachments = True
And the post process code is as follows:
import base64
import hashlib
results = playbook.functions.results.output_mail.get("content", {}).get("attachments", {})
for attachment in results:
# Base64 string of the attachment extracted from the email
base64_string = attachment.get("payload", "")
# Decode base64 string to binary data
binary_data = base64.b64decode(base64_string)
# Calculate MD5 hash
md5_hash = hashlib.md5(binary_data).hexdigest()
# Calculate SHA256 hash
sha256_hash = hashlib.sha256(binary_data).hexdigest()
hashes = "Hases of the Archive {}\nMD5 Hash: {}\nSHA256 Hash: {}".format(attachment.get("filename", ""), md5_hash, sha256_hash)
incident.addNote(hashes)