Replies: 1 comment 1 reply
-
|
Here is what we do: None of the above, but I picked the first option, as it is the most relevant to us.
// email is an `EmailModel` with an `ICollection<QueuedEmailAttachmentModel> Attachments {get; set;}`
// message is a MimeMessage
// _fileSystem is IO Abstractions IFileSystem interface
// builder is MimeKit BodyBuilder
if (email.Attachments != null)
foreach (var attachment in email.Attachments.Select(a => a))
{
if (!string.IsNullOrEmpty(attachment.StoragePath) && !string.IsNullOrEmpty(attachment.FileName))
{
var filePath = _fileSystem.Path.Combine(attachment.StoragePath, attachment.FileName);
using (var stream = _fileSystem.FileStream.New(filePath, FileMode.Open, FileAccess.Read))
{
await builder.Attachments.AddAsync(attachment.FileName, stream, ContentType.Parse(attachment.MimeType));
}
}
}
message.Body = builder.ToMessageBody(); |
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
Uh oh!
There was an error while loading. Please reload this page.
-
MimeKit has multiple ways of walking the MIME document tree. Which method do you prefer to use to navigate the MIME tree structure in your application?
Here are some quick links to these APIs:
2 votes ·
Beta Was this translation helpful? Give feedback.
All reactions