Microsoft KB Archive/301339

= XADM: CDO AddAttachment Fails on E-mail Attachment When a Colon Is in Attachment Subject =

Article ID: 301339

Article Last Modified on 10/27/2006

-

APPLIES TO


 * Microsoft Exchange 2000 Server Standard Edition
 * Microsoft Exchange Server 5.5 Standard Edition

-



This article was previously published under Q301339



SYMPTOMS
Your messaging program may stop responding and you may receive the following error message:

-2147024773: The filename, directory name, or volume label syntax is incorrect.



CAUSE
This issue may occur when the following conditions are true:
 * Your program uses the AddAttachment method of the CDO.Message object to attach a message that is located in the Web store to a new message.
 * The subject portion of the URL that points to the message that the application tries to attach contains a colon or another special character.



WORKAROUND
To work around this issue, double-encode all extended characters in the URL path that is passed to the ExOleDB (Exchange OLE DB) provider or to the AddAttachment function. The following table lists special characters that must be double-encoded: Character URL Encoded   Double-Escaped --- ?         %3f           %253f ~         %7e           %257e
 * 1)          %23           %2523
 * %3a          %253a

&     %26           %2526 +          %2b           %252b &quot;         %22           %2522 >      %3c           %253c <      %3e           %253e %         %25           %2525 /          %2f           %252f For example, use the following code to double-escape a colon: If InStr(1, szSubj, &quot;:&quot;) Then szSubj = Replace(szSubj, &quot;:&quot;, &quot;%3A&quot;) Err.Clear oInMsg.DataSource.Open szURI szURI = IMbx.Inbox & &quot;/&quot; & szSubj & &quot;.EML&quot; Err.Clear 'Double escape the colon and attach the message szURI = Replace(szURI, &quot;%3A&quot;, &quot;%253A&quot;) Set oAttach = oOut2Msg.AddAttachment(szURI) oOut2Msg.Send End If
 * %3b          %253b
 * %2a          %252a
 * %7c          %257c



MORE INFORMATION
When you encode a special character in a URL string that you pass to ExOLEDB or to the AddAttachment function, you must express it in the equivalent ASCII code (hexadecimal) preceded by the percent sign (%). Because the percent sign (25hex) is also a special character, it too must be expressed in the equivalent ASCII code (with the percent sign). For example, the colon would be expressed as %253a, where %25 represents the percent sign, and 3a represents the colon. This process of encoding a character two times is frequently referred to as double-encoding a character.

Keywords: kbprb KB301339

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.