Currently, the method AttachFromFileName({fileName}, {Content-Type}, {attachmentName}) has only fileName as required and other two including "content-type" as optional. But in the implementation, it seems its expected/required. When i implemented the attachment option with just the fileName parameter only, it throws error
Value cannot be null. (Parameter name 'text')
When i dig deeper into the source code of this, I found like its been expected to parse further down, as ContentType.Parse(text).
Either, make the "content-type" parameter as required or dont expect it further down the line, may be, derive the content type implicitly or auto detect, whichever could solve not to throw such error.
Stack trace details:
at MimeKit.Utils.ParseUtils.ValidateArguments(ParserOptions options, String text)
at MimeKit.ContentType.Parse(ParserOptions options, String text)
at MimeKit.ContentType.Parse(String text)
at FluentEmail.MailKitSmtp.MailKitSender.<>c__DisplayClass5_0.b__0(Attachment x)
at FluentEmail.Core.ListExtensions.ForEach[T](IEnumerable1 enumerable, Action1 consumer)
at FluentEmail.MailKitSmtp.MailKitSender.CreateMailMessage(IFluentEmail email)
at FluentEmail.MailKitSmtp.MailKitSender.d__3.MoveNext()
My code usage/implementation is,
if (File.Exists(file))
{
mailer.AttachFromFilename(file, attachmentName: Path.GetFileName(file));
}