How to: Access the Outlook Item that Displays the Form Region
Applies to |
---|
The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office. Project type
Microsoft Office version
For more information, see Features Available by Application and Project Type. |
A form region appears when you open an item in Microsoft Office Outlook. You can access the Outlook item in which the form region appears by using the OutlookItem property of the FormRegionControl class.
More than one type of Outlook item can display a form region. You can determine what type of Outlook item is displaying the form region and then cast the Outlook item to that type.
The following example identifies the Outlook item as a mail item and then adds the subject of the mail item to a label on the form region.
Example
Private Sub FormRegion1_FormRegionShowing(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.FormRegionShowing
If TypeOf (Me.OutlookItem) Is Outlook.MailItem Then
If Me.OutlookFormRegion.FormRegionMode = _
Outlook.OlFormRegionMode.olFormRegionRead Then
Dim mailItem As Outlook.MailItem = CType(Me.OutlookItem, _
Outlook.MailItem)
Label1.Text = "This form region contains information " & _
"about " & mailItem.Subject
End If
End If
End Sub
private void FormRegion1_FormRegionShowing
(object sender, System.EventArgs e)
{
if (this.OutlookItem is Outlook.MailItem)
{
if (this.OutlookFormRegion.FormRegionMode ==
Outlook.OlFormRegionMode.olFormRegionRead)
{
Outlook.MailItem mailItem =
(Outlook.MailItem)this.OutlookItem;
label1.Text = "This form region contains information " +
"about " + mailItem.Subject;
}
}
}
See Also
Tasks
Walkthrough: Designing an Outlook Form Region
How to: Prevent Outlook from Displaying a Form Region
How to: Add a Form Region to an Outlook Add-in Project