"+" symbol contain email file name is not opening

54 views Asked by At

I am trying to open email message by providing URL as below

mailUrl = "/Inbox/test%20mail%20%2B%20to%20verify%20%2B%20symbol.EML"

oXMLHttp.open("PROPFIND", mailUrl, false, strUser, strPass);

%20 - space

%2B - +

It returns file not found error, but file is there. The issue I am facing is, whenever + symbol used in file name, getting file not found error.

1

There are 1 answers

5
Robbi Nespu On

Because that naming convention are illegal. Avoid using non-alphanumeric characters in file names. The use of these characters can cause problems and issues, plus, file name can't be longer than 128 characters.

Read this link below, they are helpful to understand and list the symbol that need to be avoid in file name:

  1. Standard naming conventions for electronic records, rule 13
  2. Characters to Avoid in Directories and Filenames
  3. Illegal characters to avoid in filenames

Maybe you can try to sanitize input (file name) before passing to oXMLhttp.open() function such like this :

string mailUrl = "/Inbox/test%20mail%20%2B%20to%20verify%20%2B%20symbol.EML"

private static string SanitizeFileName(string name)
{
string invalidChars = Regex.Escape( new string( Path.GetInvalidFileNameChars() ) );
string invalidReStr = string.Format( @"[{0}]+", invalidChars );
return Regex.Replace( name, invalidReStr, "_" );
}

validFileName = SanitizeFileName(mailUrl);

oXMLHttp.open("PROPFIND", validFileName, false, strUser, strPass);