Hi,
I have the follwing situation:
- I add attachment (RFC822) to a MailMessage.
- The MailMessage is converted to a MimeMessage
- The MimeMessage is utimately saved into a byte array.
- At some later point the MimeMessage is loaded from the byte array, converted to a MailMessage and the attachment retrieved from the MailMessage.
Upon retrieval of the attachment from MailMessage the filename is not equal to the original value (e.g. msg.eml). It is "ATT00001.eml", which appears to be autogenerated.
Does anyone know why this is happening and how I can avoid losing the original filename?
The following code snippet is used populate attachments for a Rebex.Mail.Message.
foreach (Attachment a in message.Attachments)
{
mailMessage.Attachments.Add(new Rebex.Mail.Attachment(new MemoryStream (a.Content),
a.FileName,
a.MediaType));
}
The following code snippet is used to retrieve attachments from Rebex.Mail.Message.
foreach (Rebex.Mail.Attachment a in mailMessage.Attachments)
{
byte[] content = new byte[a.GetContentLength()];
Stream cs = a.GetContentStream();
cs.Read(content, 0, (int)cs.Length);
cs.Close();
attachments.Add(new Attachment(content, a.FileName, a.MediaType) { Id = id++ });
}