diff --git a/src/OrchardCore.Modules/OrchardCore.Email/Services/SmtpService.cs b/src/OrchardCore.Modules/OrchardCore.Email/Services/SmtpService.cs
index 82600798546..ae567b9aee1 100644
--- a/src/OrchardCore.Modules/OrchardCore.Email/Services/SmtpService.cs
+++ b/src/OrchardCore.Modules/OrchardCore.Email/Services/SmtpService.cs
@@ -128,16 +128,13 @@ private MimeMessage FromMailMessage(MailMessage message)
body.TextBody = message.Body;
}
- if (message.Attachments != null)
+ foreach (var attachment in message.Attachments)
{
- foreach (var attachment in message.Attachments)
+ // Stream must not be null, otherwise it would try to get the filesystem path
+ if (attachment.Stream != null)
{
- // Stream must not be null, otherwise it would try to get the filesystem path
- if (attachment.Stream != null)
- {
- body.Attachments.Add(attachment.Filename, attachment.Stream);
- }
- }
+ body.Attachments.Add(attachment.Filename, attachment.Stream);
+ }
}
mimeMessage.Body = body.ToMessageBody();
diff --git a/src/OrchardCore/OrchardCore.Email.Abstractions/MailMessage.cs b/src/OrchardCore/OrchardCore.Email.Abstractions/MailMessage.cs
index 7d2c4e4fcfd..02a70a93d05 100644
--- a/src/OrchardCore/OrchardCore.Email.Abstractions/MailMessage.cs
+++ b/src/OrchardCore/OrchardCore.Email.Abstractions/MailMessage.cs
@@ -56,8 +56,8 @@ public class MailMessage
public bool IsBodyHtml { get; set; }
///
- /// Gets or sets the message attachments.
+ /// The collection of message attachments.
///
- public IEnumerable Attachments { get; set; }
+ public List Attachments { get; } = new List();
}
}