MailEnvelope Object

InfoPath Developer Reference

Represents a custom e-mail message in a Microsoft Office InfoPath 2007 form.

Version Information
 Version Added:  InfoPath 2003

Remarks

The MailEnvelope object provides a number of properties that can be used to programmatically create a custom e-mail message within the default e-mail editor, and it attaches the currently open InfoPath form to the message.

After the e-mail message is created, the default e-mail editor will display the e-mail message; users can then inspect and edit the e-mail message before sending it.

Bb229861.vs_note(en-us,office.12).gif  Note
The MailEnvelope object cannot be used to send the e-mail messages it creates; users must manually send the e-mail messages.

You can also use the ShowMailItem method of the UI object to programmatically create e-mail messages.

The MailEnvelope object is accessed through the MailEnvelope property of the Window object.

Example

In the following example from the Meeting Agenda sample form, the MailEnvelope property of the Window object is used to set a reference to the MailEnvelope object that is associated with the currently active window. The code then uses the MailEnvelope object to create a custom e-mail message.

JScript
  function SendMeetingAgendaBtn::OnClick(oEvent)
{
   var rgRecipients = new Array();
   var xmlRecipients = getNodeList("/mtg:meetingAgenda/
      mtg:attendees/mtg:attendee/mtg:emailAddressPrimary");
   var xmlRecipient;

while (xmlRecipient = xmlRecipients.nextNode()) rgRecipients.push(xmlRecipient.text);

try { var oEnvelope = Application.ActiveWindow.MailEnvelope;

  oEnvelope.Subject = getNode("/mtg:meetingAgenda/mtg:subject").text;
  oEnvelope.To = rgRecipients.join("; ");
  oEnvelope.Visible = true;

} catch(ex) { XDocument.UI.Alert(ex.description); } }

See Also