File won't open when writing attachment file stream to file #449
Unanswered
Minisaints
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Here's how I save attachments files in my var parser = new WebhookParser();
var inboundEmail = await parser.ParseInboundEmailWebhookAsync(Request.Body).ConfigureAwait(false);
if (inboundEmail.Attachments != null)
{
foreach (var attachment in inboundEmail.Attachments)
{
byte[] content = new byte[attachment.Data.Length];
attachment.Data.Read(content, 0, (int)attachment.Data.Length);
var filePath = System.IO.Path.Combine("C:\\Temp", attachment.FileName);
System.IO.File.WriteAllBytes(filePath, content);
}
} Hopefully this helps |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey,
I'm trying to write the attachment stream to an actual file binary using a file stream but the file won't open. The file binary opened in notepad appears to resemble normal binary data too.
Am I missing something?
Beta Was this translation helpful? Give feedback.
All reactions