Export (0) Print
Expand All
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

How to: Add Voting Options to a Mail Item

This example shows how to use the VotingOptions property of the MailItem object to add voting options to an e-mail message.

Programming Applications for Office Outlook 2007

The following code example is an excerpt from Programming Applications for Microsoft Office Outlook 2007, from Microsoft Press (ISBN 9780735622494, copyright Microsoft Press 2007, all rights reserved).

Buy this book

Sample chapters

Voting options on messages are used to give message recipients a list of choices and to track their responses. To create voting options programmatically, set a string that is a semicolon-delimited list of values for the VotingOptions property of a MailItem object. The values for the VotingOptions property will appear under the Vote command in the Respond group in the ribbon of the received message.

In the following example, OrderPizza creates voting options in a new mail message. OrderPizza first creates a MailItem, and then sets the VotingOptions property to “Cheese; Mushroom; Sausage; Combo; Veg Combo”, and the Subject property to “Pizza Order”. When the “Pizza Order” message is sent, the voting options appear to recipients. For each response received, the recipient’s choice will be tallied on the Tracking page of the message in the sender’s Sent Items folder.

If you use Microsoft Visual Studio to test this code example, you must first add a reference to the Microsoft Outlook 14.0 Object Library component and specify the Outlook variable when you import the Microsoft.Office.Interop.Outlook namespace. The using statement must not occur directly before the functions in the code example but must be added before the public Class declaration. The following line of code shows how to do the import and assignment in C#.

using Outlook = Microsoft.Office.Interop.Outlook;
private void OrderPizza()
{
    Outlook.MailItem mail = (Outlook.MailItem)Application.CreateItem(
        Outlook.OlItemType.olMailItem);
    mail.VotingOptions = “Cheese; Mushroom; Sausage; Combo; Veg Combo;”
    mail.Subject = “Pizza Order”;
    mail.Display(false);
}

Other Resources

Show:
© 2014 Microsoft