Working with Voting Option Using MapiMessage
Creating Voting Option Using MapiMessage
Microsoft Outlook allows users to create a poll when composing a new message. It allows them to include voting options such as Yes, No, Maybe, etc. Aspose.Email allows the same while creating a new Outlook message. The FollowUpOptions class provides the VotingButtons property that can be used to set or get the value of voting options. This article provides a detailed example of creating a MapiMessage with voting options for creating a poll.
Creating a Poll using MapiMessage
The following code snippet shows you how to create a poll, the FollowUpManager class can be used as shown in the following code snippet.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
string address = "firstname.lastname@aspose.com"; | |
IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain"); | |
MailMessage message = CreateTestMessage(address); | |
// Set FollowUpOptions Buttons | |
FollowUpOptions options = new FollowUpOptions(); | |
options.VotingButtons = "Yes;No;Maybe;Exactly!"; | |
client.Send(message, options); |
Reading Voting Options from a MapiMessage
The following code snippet shows you how to read voting options from a MapiMessage.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
MapiMessage message = MapiMessage.FromFile(fileName); | |
// This method can be useful when except voting buttons it is necessary to get other parameters (ex. a category) | |
FollowUpOptions options = FollowUpManager.GetOptions(message); | |
// Voting buttons will be introduced as a string with semi-column as a separator | |
string votingButtons = options.VotingButtons; |
Reading Only Voting Buttons
The following code snippet shows you how to read only voting buttons.
Adding a voting button to an Existing Message
The following code snippet shows you how to add a voting button to an existing message.
Deleting a Voting button from a Message
The following code snippet shows you how to delete the vote button from a Message.
Read the Vote Results Information
The following code snippet shows you how to read the vote results information.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
MapiMessage msg = MapiMessage.FromFile(dataDir + @"AddVotingButtonToExistingMessage.msg"); | |
foreach (MapiRecipient recipient in msg.Recipients) | |
{ | |
Console.WriteLine(string.Format("Recipient: {0}", recipient.DisplayName)); | |
// Get the PR_RECIPIENT_AUTORESPONSE_PROP_RESPONSE property | |
Console.WriteLine(string.Format("Response: {0}", recipient.Properties[MapiPropertyTag.PR_RECIPIENT_AUTORESPONSE_PROP_RESPONSE].GetString())); | |
// Get the PR_RECIPIENT_TRACKSTATUS_TIME property | |
Console.WriteLine(string.Format("Response time: {0}", recipient.Properties[MapiPropertyTag.PR_RECIPIENT_TRACKSTATUS_TIME].GetDateTime())); | |
Console.WriteLine(); | |
} |
Sample Methods Used In Examples
The following code snippet shows you how to create the sample message used in examples.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
private static MapiMessage CreateTestMessage(bool draft) | |
{ | |
MapiMessage msg = new MapiMessage("from@test.com","to@test.com","Flagged message","Make it nice and short, but descriptive. The description may appear in search engines' search results pages..."); | |
if (!draft) | |
{ | |
msg.SetMessageFlags(msg.Flags ^ MapiMessageFlags.MSGFLAG_UNSENT); | |
} | |
return msg; | |
} |