0 votes
by (160 points)
edited by

Hello,
I have an issue when instantiating new Attachment

   using (Stream str = new MemoryStream(imap.MessageB))
      {
        attachment = new Attachment();
        attachment.SetContent(str, filename);
      }

with filename="Invoice17/12/9813".
I have many received Gmail mails with attachment that have the '/' inside the filename with no issue. But using Rebex I have "Invalid character at position.." (parameter name).
I tried to change MimeOption to allow everything but still got the error. Any solution?
Thank you

Applies to: Rebex Secure Mail

1 Answer

+1 vote
by (3.9k points)
selected by
 
Best answer

Hello,

the problem is that in many operation systems the '/' is recognized as directory separator, so the better practice is to omit such character. But if you really want to use it, there is a workaround:

using (Stream str = new MemoryStream(imap.MessageB))
{
    attachment.SetContent(str, "dummy");
    attachment.ContentType.Parameters["name"] = "invoice/17/12/9813";
    attachment.ContentDisposition.Parameters["filename"] = "invoice/17/12/9813";
}
...