Extension is not generated by Mail.dll - it is specified by the sender when you set the file name:
Change this line:
attachment.FileName = "test";
to:
attachment.FileName = "test.jpg";
You can also use MimeData SetFileName method:
SetFileName(string fileName, bool guessContentType)
Which sets content type useing the extension.
MailBuilder builder = new MailBuilder();
byte[] file = ..;
MimeData attachment = new MimeFactory().CreateMimeData();
attachment.Data = file;
attachment.SetFileName("test.jpg", true)
builder.AddAttachment(attachment);
Finally have in mind that you can load file directly from disk:
MailBuilder builder = new MailBuilder();
builder.AddAttachment("c:\\text.jpg");
This will set both: content-type and file name.