Share via


MailEnvelope2.Available property

Gets whether the other properties of the MailEnvelope2 object are available to code running in the form.

Namespace:  Microsoft.Office.Interop.InfoPath.SemiTrust
Assembly:  Microsoft.Office.Interop.InfoPath.SemiTrust (in Microsoft.Office.Interop.InfoPath.SemiTrust.dll)

Syntax

'Declaration
ReadOnly Property Available As Boolean
    Get
'Usage
Dim instance As MailEnvelope2
Dim value As Boolean

value = instance.Available
bool Available { get; }

Property value

Type: System.Boolean
true if the other properties of the MailEnvelope2 object are available to code running in the form; otherwise false.

Remarks

The Available property is use to test whether the form is open in Microsoft Office Outlook 2007. If a form is sent as an e-mail attachment to a user running Microsoft Office Outlook 2007, the form will open within Outlook. In this context, it is not appropriate to programmatically create an e-mail message for attaching and sending the currently open InfoPath form because the form and e-mail message to which it is attached are already open in Outlook, and the Available property will return false. If the form is opened in InfoPath, the Available property will return true and form code can use the properties of the MailEnvelope2 object.

Because the Available property is new to Microsoft InfoPath, you must declare and cast to the MailEnvelope2 type to access this method. For more information, see How to: Use Microsoft.Office.Interop.InfoPath.SemiTrust Members That Are Not Compatible with InfoPath 2003.

This member can be accessed without restrictions.

Examples

The following example sets a reference to the MailEnvelopeObject object, uses the Available property to determine if the form is open Microsoft Office Outlook 2007, and if so, in sets envelope properties, and then displays the e-mail envelope.

// Set a reference to the MailEnvelope2 object.
MailEnvelope2 myEnv = 
   (MailEnvelope2)thisApplication.ActiveWindow.MailEnvelope;
if (myEnv.Available)
{
   // Specify addresses and subject.
   myEnv.To = "someone@example.com";
   myEnv.CC = "someone@example.com";
   myEnv.BCC = "someone@example.com";
   myEnv.Subject = "Open this form";

   // Display form with e-mail envelope.
   myEnv.Visible = true;
}
else
{
   // The form is open in Outlook, and code will not run.
   thisXDocument.UI.Alert("This form is open in Outlook.");
}

See also

Reference

MailEnvelope2 interface

MailEnvelope2 members

Microsoft.Office.Interop.InfoPath.SemiTrust namespace