I am creating a method, which can send out emails with ics/calendar entry attached to it.
If I test the code by really sending out an email, it works with no problem, but if I try to get the Attachment in the Test with the nDumbster package, it does not get any attachments. I a now confused, if it should be in the Attachments or not and what the problem might be!
I imagine, that the problem lies at this following line:
var av = AlternateView.CreateAlternateViewFromString(str.ToString(), new ContentType("text/calendar"));
message.AlternateViews.Add(av);
The variable "str" is a StringBuilder with the code for the ics.
This is a small snippet of the Test I do. The first 3 lines work fine, but the last 2 fail (The test logic I did not include here, just the asserts)
var message = _simpleSmtpServer.ReceivedEmail.ToList()[0];
Assert.Equal("GREAT IMPORTANT EMAIL", message.Subject);
Assert.Equal(new List<MailAddress> { new("[email protected]"), new("[email protected]") }, message.To);
var attachment = message.Attachments.First();
Assert.Equal("text/calendar", attachment.ContentType.MediaType);