Microsoft KB Archive/278358

= PRB: File Attached with CDO Has Incorrect Filename =

Article ID: 278358

Article Last Modified on 3/4/2004

-

APPLIES TO


 * Microsoft Collaboration Data Objects 1.2
 * Microsoft Collaboration Data Objects 1.21

-



This article was previously published under Q278358



SYMPTOMS
When you open an attachment that was added to a message by using CDO, the file name does not match what was originally set in the .Name property of the attachment.



CAUSE
CDO determines the name of the file from the CdoPR_ATTACH_LONG_FILENAME property, not from the .Name property.



RESOLUTION
Set the PR_ATTACH_LONG_FILENAME property of the attachment in addition to the .Name property. PR_ATTACH_LONG_FILENAME determines the name that is used for the file that is opened, including the extension that determines which application opens the file. objAttach = objMessage.Attachments.Add objAttach.Type = CdoFileData objAttach.Position = 0 objAttach.Fields.Add CdoPR_ATTACH_LONG_FILENAME, strDisplayFileName objAttach.ReadFromFile(strSourceFile) objAttach.Name = strDisplayFileName NOTE: The icon of the attachment is set according to the extension of the file name that is specified in the call to the ReadFromFile method.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
The following code sample demonstrates the problem. When this code is used to attach a file, the file name is not set correctly, even though the correct icon is displayed and the display name of the attachment is correct. objAttach = objMessage.Attachments.Add objAttach.Type = CdoFileData objAttach.Position = 0 objAttach.ReadFromFile(strSourceFile)

Keywords: kbmsg kbprb KB278358

-

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

© Microsoft Corporation. All rights reserved.