How to modify attachment's local menu

Add-in Express™ Support Service
That's what is more important than anything else

How to modify attachment's local menu
 
Subscribe
kollanyipeter




Posts: 8
Joined: 2021-05-14
Hi,

if a received message has an attachment, how can I change the attachment's local menu? Can I find any help or a sample program for this?


Regards,

Péter
Posted 03 Jun, 2021 09:13:37 Top
Andrei Smolin


Add-in Express team


Posts: 17740
Joined: 2006-05-11
Hello Péter,

Put a TadxRibbonContextMenu onto the add-in module, set the Ribbons property to msrOutlookMailRead and/or msrOutlookExplorer - this reflects the fact that the attachment context menu can be shown in explorer and mail read inspector windows - and use the ContextMenuNames property editor to add the 'Outlook.Explorer.ContextMenuAttachments' and 'Outlook.Mail.Read.ContextMenuAttachments' context menu names to the list of context menu names that will show custom control(s) specified in the Controls property.

Below is a TadxRibbonContextMenu showing a button on the ContextMenuAttachments context menu in explorer and mail read inspector windows in Outlook 2010+.

  object adxRibbonContextMenu1: TadxRibbonContextMenu
    ContextMenuNames.Strings = (
      'Outlook.Explorer.ContextMenuAttachments'
      'Outlook.Mail.Read.ContextMenuAttachments')
    Left = 80
    Top = 216
    ControlTypes = {0100000007000000}
    Controls_ = <
      item
        Id = 'adxRibbonButton50EB42B075B448A9849E9D866EA1250F'
        Caption = 'adxRibbonButton2'
        Ribbons = [msrOutlookMailRead, msrOutlookExplorer]
        Ribbons2010 = [msrOutlookExplorer2010]
      end>
    Ribbons = [msrOutlookMailRead, msrOutlookExplorer]
    Ribbons2010 = [msrOutlookExplorer2010]
  end


You can find context menu names and IDs of built-in Ribbon controls in the download at https://www.microsoft.com/en-us/download/details.aspx?id=36798.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 04 Jun, 2021 02:18:54 Top
kollanyipeter




Posts: 8
Joined: 2021-05-14
Thank You, it works fine!

Just one more little help: when I click the button, from where can I know, which attachment file is the actual?

Regards,

Péter
Posted 04 Jun, 2021 07:14:38 Top
Andrei Smolin


Add-in Express team


Posts: 17740
Joined: 2006-05-11
Hello Péter,

Event handlers of Ribbon components provide context objects. You get such an object via Control.Context. The context object in this case should be an Outlook.AttachmentSelection object; see https://docs.microsoft.com/en-us/office/vba/api/outlook.attachmentselection.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 04 Jun, 2021 10:06:51 Top