Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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.

↑ Back to the top


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.

↑ Back to the top


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
#          %23           %2523
:          %3a           %253a
;          %3b           %253b
&      %26           %2526
+          %2b           %252b
*          %2a           %252a
"          %22           %2522
>       %3c           %253c
<       %3e           %253e
|          %7c           %257c
%          %25           %2525
/          %2f           %252f

For example, use the following code to double-escape a colon:
If InStr(1, szSubj, ":") Then
  szSubj = Replace(szSubj, ":", "%3A")
  Err.Clear
  oInMsg.DataSource.Open szURI
  szURI = IMbx.Inbox & "/" & szSubj & ".EML"
  Err.Clear
  'Double escape the colon and attach the message 
  szURI = Replace(szURI, "%3A", "%253A")
  Set oAttach = oOut2Msg.AddAttachment(szURI)
  oOut2Msg.Send
End If

↑ Back to the top


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.

↑ Back to the top


Article Info
Article ID : 301339
Revision : 4
Created on : 1/1/0001
Published on : 1/1/0001
Exists online : False
Views : 327