SetFileName method is a fluent equivalent of MimeData.FileName property, the idea is that there are no side effects in using this method.
We'll add the overload on IFluentAttachment (SetFileName(string fileName, bool guessContentType)) and similar method to MimeData class.
Fluent API:
byte[] data = File.ReadAllBytes("c:\\tmp.zip");
IMail email = Fluent.Mail
.Text("email body")
.AddAttachment(data).SetFileName("report.zip", true)
.Create();
Assert.AreEqual("author.zip", email.NonVisuals[0].FileName);
Assert.AreEqual(ContentType.ApplicationZip, email.NonVisuals[0].ContentType);
MailBuilder API:
byte[] data = File.ReadAllBytes(TestConstants.FileInTest("me.zip"));
MailBuilder builder = new MailBuilder();
builder.Text = "email body";
MimeData mime = builder.AddAttachment(data);
mime.SetFileName("author.zip", true);
IMail email = builder.Create();
Assert.AreEqual("author.zip", email.NonVisuals[0].FileName);
Assert.AreEqual(ContentType.ApplicationZip, email.NonVisuals[0].ContentType);