none
Outlook 2007, Application.AttachmentContextMenuDisplay not firing RRS feed

  • Question

  • Hello everyone,

    does anyone know why the Application.ItemContextmenuDisplay works for me. But the Application.AttachmentContextmenuDisplay doesn't fire at all?

    When I debug it I only enter the itemcontextmenudisplay event. Am I understanding wrong when the attachmentcontextmenudisplay event should be fired? I thought when i rightclick an attachment in an email.

    Here is my simple code

    Imports System.IO

    Imports System.Diagnostics

    Imports System.Drawing

    Imports System.Windows.Forms

    Imports Microsoft.Office.Interop.Outlook

    Public Class ThisAddIn 

        Private Sub ThisAddIn_Startup() Handles Me.Startup
        End Sub
        Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
        End Sub

        Private Sub UpdateAttUpdate(ByVal CommandBar As Office.CommandBar, ByVal Attachments As AttachmentSelection) Handles Application.AttachmentContextMenuDisplay
        End Sub

        Private Sub OnItemUpdate() Handles Application.ItemContextMenuDisplay
        End Sub



    • Edited by Tastic11 Monday, September 9, 2013 7:33 AM
    Friday, September 6, 2013 6:09 AM

Answers

  • After some testing I found out that attachmentcontextmenudisplay simply does not work for richtext emails, only for html format.

    Is there anyway to make it work for rtf as well?

    The standard format in this company is rfl and they won't change it because it doesn't work in this add-in.


    • Marked as answer by Tastic11 Wednesday, September 11, 2013 10:47 AM
    • Edited by Tastic11 Wednesday, September 11, 2013 12:15 PM
    Wednesday, September 11, 2013 10:47 AM

All replies

  • Is at least 1 attachment selected at the time? I believe that's a requirement for the event to fire.

    Ken Slovak MVP - Outlook

    Friday, September 6, 2013 6:02 PM
  • Yes, I have tried selecting one attachment, multiple attachment, accessing the attachment  with and without opening the mailitem in another window.

    Has noone else encountered this problem with applicationcontextmenudisplay?

    I have tested itemcontextmenudisplay and foldercontextmenudisplay and they both fire how I expected. I also tried contextmenuclose, this handler also only fires if I close the folder or item contextmenu but when i close the attachment contextmenu, nothing happens.

    Any suggestions or direction where this problem could lie would really help me out.

    Monday, September 9, 2013 5:19 AM
  • If you put this macro into the Outlook VBA project in the ThisOutlookSession class, and the Outlook VBA project is allowed to run code, do you see the message if you select 1 attachment on an item and right-click it?

    Private Sub Application_AttachmentContextMenuDisplay(ByVal CommandBar As Office.CommandBar, ByVal Attachments As AttachmentSelection)
        If (Attachments.Count = 1) Then
            MsgBox Attachments.Item(1).DisplayName
        End If
    End Sub

    The event handler is working here for me on an Outlook 2007 test platform.


    Ken Slovak MVP - Outlook

    Monday, September 9, 2013 1:59 PM
  • Hi Ken, thx for sticking with me.

    using:

    Sub Start()
        MsgBox "Macro started"
    End Sub

    Private Sub Application_AttachmentContextMenuDisplay(ByVal CommandBar As Office.CommandBar, ByVal Attachments As AttachmentSelection)
        If (Attachments.Count = 1) Then
            MsgBox Attachments.Item(1).DisplayName
        End If
    End Sub

    Private Sub Application_ContextMenuClose(ByVal ContextMenu As OlContextMenu)
        MsgBox "ContestMenuClose fires"
    End Sub

    When I close any other context menu except the attachment context menu the Aplpication_ContextMenuClose handler is called. However, neither the AttachmentContextMenuDisplay nor the ContextMenuClose gets fired for the attachment context menu (In this case I was rightclicking 1 pdf attachment on the right-side panel of outlook after chosing an email).

    From your answer it seems to be a problem specific to this Outlook I am using. Do you have any idea what could cause this?

    Btw, how do i verify this account so I can post pictures? Maybe that will help.

    Tuesday, September 10, 2013 12:34 PM
  • Sorry, I have no idea how you'd verify your account.

    If that simple macro doesn't work but others do I really don't know what could be the problem. Are you sure you selected an item in Inbox or another folder and then right-clicked on one of the attachments in the attachment well?

    I suppose you could try an Office repair, but frankly I'm not at all sure it would do anything. Do you have access to another computer where you could test the same code?


    Ken Slovak MVP - Outlook

    Tuesday, September 10, 2013 2:00 PM
  • Yes I have selected an email and rightclicked one item of its attachment(which was inside the body of the email).

    I am trying to figure out if its not working only with Outlook 2007 SP3 MSO. I have tryed it on different computers as well, however they all run that version. It didn't work on any so far.

    The outlook 2007 test plattform you talked about, is it available for download?

    Are there some tools or options that prevent or block procedures from being called?


    • Edited by Tastic11 Wednesday, September 11, 2013 9:10 AM
    Wednesday, September 11, 2013 6:15 AM
  • After some testing I found out that attachmentcontextmenudisplay simply does not work for richtext emails, only for html format.

    Is there anyway to make it work for rtf as well?

    The standard format in this company is rfl and they won't change it because it doesn't work in this add-in.


    • Marked as answer by Tastic11 Wednesday, September 11, 2013 10:47 AM
    • Edited by Tastic11 Wednesday, September 11, 2013 12:15 PM
    Wednesday, September 11, 2013 10:47 AM
  • The test platform I used is in my own private network, on one of my development and test virtual machines. It is not available to anyone outside my own network.

    You can skip running some code instruction lines in the debugger.


    Ken Slovak MVP - Outlook

    Wednesday, September 11, 2013 1:52 PM
  • That makes total sense. RTF attachments are inline, embedded attachments and are not in the "attachment well". The context menu event handler is only for attachments in the well.

    There are many other reasons not to use RTF. Among them are that it doesn't travel well over the Internet, only Outlook (and Eudora) can understand it, if the TNEF is corrupted or misinterpreted in some way the recipient receives a Winmail.dat attachment, and various others. But that's your company's business.

    I'd guess this is a "by design" bug that wouldn't be considered for a fix, plus Outlook 2007 is out of support for anything but security fixes. The only way to tell for sure though would be to open a support case with MS support and see if they'd consider a hot fix that your company would have to pay for.


    Ken Slovak MVP - Outlook

    Wednesday, September 11, 2013 1:56 PM