Help with Sending HTML Attachments in PowerShell
Asked by
TechWizard123
I'm trying to send an email with an HTML attachment using PowerShell, but I'm running into an error that says my attachment data is corrupted because the property value is too big. Here's the specific error message:
"Send-MgUserMail : The object data is corrupted. The value of property AttachLongFileName is too large and requires streaming. Status: 400 (BadRequest) ErrorCode: ErrorPropertyTooBig"
I've shared my script below, which generates an HTML file from a CSV. I'm not sure if the issue is related to how I'm defining the file name or the content itself. Any help would be appreciated!
Answers
Hey! It looks like your variable `$file` for the attachment name is never actually defined in your script. Make sure to set that somewhere so it knows what file to attach.
Reply to this answer
From the error, it seems like the attachment file size might exceed some limits. How large is your generated file? If itโs beyond the limits set by your Exchange server, that could be the issue. Also, double-check that the `$file` variable is properly set for the attachment.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions