none
attachment.Name returns a kind of generic file name instead of real file name. RRS feed

  • Question

  • I work with Exchange Server 2007 SP1 Web Services and EWS client 1.1.

    I want to get a message attachment that is an image (123456.tif). I can easily get the attached file with the code below, but  it has a name Tagged Image File Format.tif instead of 123456.tif as i expected. The real file name is important to me as it contains a reference info in it.

                    // Bind to an existing message item, requesting its Id property plus its attachments collection.

                    EmailMessage message = EmailMessage.Bind(service, new ItemId(strId), new PropertySet(BasePropertySet.FirstClassProperties, EmailMessageSchema.Attachments));

                    // Iterate through the attachments collection and load each attachment.

                    foreach (Attachment attachment in message.Attachments)

                    {

                        if (attachment is FileAttachment)

                        {

                            FileAttachment fileAttachment = attachment as FileAttachment;

                            fileAttachment.Load(sTempAttachFolderPath + fileAttachment.Name);

                        }

                        else // Attachment is an item attachment.

                        {

                            // Load attachment into memory and write out the subject.

                            ItemAttachment itemAttachment = attachment as ItemAttachment;

                            itemAttachment.Load();

                        }

                    }

    fileAttachment.Name property in highlighted line returns a generic file name  -  not the actual file name.

    In my case I have an attachment name 123456.tif, but a Name property returns Tagged Image File Fomat.tif

    Does anyone have an idea how to get real attachment file name 123456.tif ?

    --kengures

    Friday, December 9, 2011 5:27 PM

All replies