none
outlook plug-in accessory storage address how to get RRS feed

  • Question

  • attachment methods getFilePath and GetTemporaryFilePath members are unable to obtain. Code is shown below

    void Application_ItemSend(object Item, ref bool Cancel)
    {

    Cancel = true;
    Outlook.MailItem mailItem = Item as Outlook.MailItem;

    if (mailItem != null)
    {          
    var attachments = mailItem.Attachments;
    string str;
                    foreach (Outlook.Attachment attachment in attachments)
                    {
                        try
                        {
                            str = attachment.GetTemporaryFilePath();
                        }
                        catch { 

                        }
                    }
                }

    }

    Wednesday, March 18, 2015 8:31 AM

Answers

  • Unless the attachment is a link to a file somewhere, the attachment is in the attachments table on the item. There is no address in that case. If you want to operate on the attachment you can save it to the file system and manipulate it there. If you change it you can remove the original attachment and add the changed one from the file system.

    Ken Slovak MVP - Outlook

    • Marked as answer by tk1223108078 Saturday, March 21, 2015 9:25 AM
    Thursday, March 19, 2015 9:14 PM

All replies

  • Hello,

    The GetTemporaryFilePath method is only valid for those attachments whose Type property is OlAttachmentType.olByValue. That means that the attachment is a copy and that the copy can be accessed even if the original file is removed. For other attachment types, the GetTemporaryFilePath method returns an error. Is that the case?

    GetTemporaryFilePath also returns an error when accessing an Attachment object in an Attachments collection or in the AttachmentSelection object. UseGetTemporaryFilePath only in attachment event callbacks listed below for various Microsoft Outlook items:

    •  AttachmentAdd
    • AttachmentRead
    • AttachmentRemove
    • BeforeAttachmentAdd
    • BeforeAttachmentPreview
    • BeforeAttachmentRead
    • BeforeAttachmentSave
    • BeforeAttachmentWriteToTempFile

    Wednesday, March 18, 2015 9:29 AM
  • Before sending out the message I want to get the address of the mail attachments, in order to operate on its own
    Wednesday, March 18, 2015 10:22 AM
  • What address are you looking for???

    Did you have a chance to check out the Type property of the Attachment? What value does it return?

    Wednesday, March 18, 2015 10:26 AM
  • Hi,

    I think you mean outlook secure temporary file folder, the attachments are in this folder before save the mail.

    # Attachments remain in the Outlook Secure Temporary File folder when you exit Outlook 2010, Outlook 2007, or Outlook 2003

    https://support.microsoft.com/en-us/kb/817878

    To get this folder path, we need to use GetTemporaryFilePath method in some specific events (as Eugene said), the attachement type is OlAttachmentType.olByValue.

    In the ItemSend event, we can’t get that path through outlook object model, maybe you could get the path through API.

    # Deleting Outlook Temporary Files

    http://social.technet.microsoft.com/wiki/contents/articles/6499.deleting-outlook-temporary-files.aspx

    I suggest that you could get the path in AttachmentAdd event.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, March 19, 2015 7:19 AM
    Moderator
  • Unless the attachment is a link to a file somewhere, the attachment is in the attachments table on the item. There is no address in that case. If you want to operate on the attachment you can save it to the file system and manipulate it there. If you change it you can remove the original attachment and add the changed one from the file system.

    Ken Slovak MVP - Outlook

    • Marked as answer by tk1223108078 Saturday, March 21, 2015 9:25 AM
    Thursday, March 19, 2015 9:14 PM
  • thank you ,I also found this registry value, but in the draft e-mail attachments stored address is different
    Friday, March 20, 2015 5:31 AM
  • Hi,

    For the draft mail, the attachments aren’t store in the local, what address that you want to get?

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, March 20, 2015 7:59 AM
    Moderator
  • However, when sending attachments will still be sent, indicating that attachment is recorded. These accessories are not stored locally it?
    Friday, March 20, 2015 10:45 AM
  • They are embedded into the mail item object. You will not find them on the disk.
    Friday, March 20, 2015 11:02 AM
  • Yes, it is only by adopting the above method.""If you want to operate on the attachment you can save it to the file system and manipulate it there. If you change it you can remove the original attachment and add the changed one from the file system."
    Friday, March 20, 2015 12:38 PM