How is it possible to save an e-mail on disk with the help of EWS in PowerShell? I've searched the internet and found some answers, but that's all for C# or VB.
The code I have now does everything I need, copy the e-mail to the correct folder in MS Outlook and so on, but I can't seem to figure out how to save the message in a folder ($ENV:Temp
) on disk.
This can be in the format EML or MSG, that doesn't matter to me, but it needs to be saved with everything it has (body, attachments, From, To, ..).
I've tried $Mail | Out-File "$env:TEMP\test.eml"
, and it does indeed generate a 15 KB file but it appears to be empty when I open it with MS Outlook.
Thank you for your help.
In the meantime, I found the solution: