PRB: File Attached with CDO Has Incorrect Filename (278358)



The information in this article applies to:

  • Collaboration Data Objects (CDO) 1.2
  • Collaboration Data Objects (CDO) 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.

MORE INFORMATION

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)
				

Modification Type:MinorLast Reviewed:3/4/2004
Keywords:kbMsg kbprb KB278358