How to reference current Outlook item

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

How to reference current Outlook item
 
Lance Friedemann




Posts: 24
Joined: 2017-02-10
How do you reference the current Outlook item in Add-in Express?

When using the default Visual Studio Outlook Add-in you just use:

Me.MailItem

What is the equivalent way to do this in Add-In Express for Outlook?
Posted 11 Feb, 2017 20:09:09 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Lance,

Lance Friedemann writes:
Me.MailItem


What is Me in this context? Is it a Form Region? If so, from the code of an Add-in Express inspector region, you can get the item, for which the region is shown, in this way:

dim insp as Outlook.Inspector = Me.InspectorObj
If (insp IsNot Nothing) Then ' if insp is Nothing, the region is shown in an Explorer window
    dim item as object = insp.CurrentItem
    if (TypeOf item is Outlook.MailItem) Then
        dim mail as Outlook.MailItem = Ctype(item as Outlook.MailItem)
        ' use mail here
    End If 
    Marshal.ReleaseComObject(item)
End If



Andrei Smolin
Add-in Express Team Leader
Posted 13 Feb, 2017 05:18:02 Top