How to base64-encode excel for microsoft graph api /sendmail attachment
- Step 1Upload the Excel file to attach — Drop the .xlsx report. FileReader encodes it to Base64.
- Step 2Copy the Base64 string — Copy the raw Base64 string (without the data URI prefix) for the contentBytes field.
- Step 3Add to your Graph API request body — { '@odata.type': '#microsoft.graph.fileAttachment', name: 'report.xlsx', contentType: '...xlsx...', contentBytes: '<your-base64>' }
Frequently asked questions
What is the maximum attachment size for Graph API sendMail?+
Up to 3 MB for inline attachments in the request body. For larger files, use the Graph API upload session (resumable upload) instead.
Can I also use this for Teams channel message attachments via Graph API?+
Yes. Teams attachments via Graph API also use the Base64 contentBytes pattern for small files.
Should I include the data URI prefix (data:...;base64,) in contentBytes?+
No. Microsoft Graph API expects raw Base64 only in the contentBytes field — without the data URI prefix.
Privacy first
Every JAD Excel tool runs entirely in your browser using SheetJS and ExcelJS. Your spreadsheets, formulas, and data never leave your device — verified by zero outbound network requests during processing.