简体   繁体   中英

How to show the Outlook email attachment preview for a specified attachment

I have a custom pane for emails in Outlook 2013, using VSTO. It lists the attachments in a ListView and allows conversion operations to be performed on the attachments:

在此处输入图片说明

The user can normally press on an attachment to get a preview pane for the selected attachment. I need to duplicate that preview action when the matching attachment is selected in my ListView. This will allow them to select one attachment, see the preview, then choose which type of document it is (ID doc, CV etc) without having to move back and forth between my custom panel and the usual list of attachments.

I have Googled various terms, but this seems to too obscure to find. I am hoping there is an Outlook 2013 VSTO expert out there that will know where to start with this. The Inspector.AttachmentSelection is a starting point, but that is read-only .

My C# selection change handler is shown below (all error checking removed to simplify it):

private void listview_SelectedIndexChanged(object( sender, EventArgs e)
{
     ListView listView = sender as ListView;
     ListViewItem listViewItem = listView.SelectedItems[0];
     Attachment attachment = lvi.Tag as Attachment;
     Inspector inspector = Globals.ThisAddIn.Application.ActiveInspector();

     // How to preview the attachment in the inspector???
}

Update:

As a fallback, I am able to go the other way, by catching the Inspector.AttachmentSelectionChange event as shown below and selecting items in my ListView , but I would prefer to be able to select the attachments from my ListView and that cause the AttachmentSelection to change:

    void inspector_AttachmentSelectionChange()
    {
        this.attachmentListView.SelectedItems.Clear();
        foreach (Attachment selection in this.Inspector.AttachmentSelection)
        {
            foreach (ListViewItem item in this.attachmentListView.Items)
            {
                if (item.Tag as Attachment == selection)
                {
                    item.Selected = true;
                }
            }
        }
    }

Unfortunately there's nothing in the Outlook Object Model (or Redemption) that allows you to set the selected attachment.

However, it may be possible to select it using some Win32API commands to set the focus on the attachment selector region. If you use Spy++ you can see that it has a specific window handle (0007096E; AfxWndW). When that window is activated, you could issue TAB keystroke commands to select an attachment. I'm not sure though how to activate a specific attachment; TAB seems to be the only keyboard command in use for that window.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM