Creating and Managing Voting Options
Microsoft Outlook enables users to create a poll while composing a new email, allowing them to include voting options such as Yes, No, Maybe, and more. Similarly, Aspose.Email provides the functionality to create polls when generating a new Outlook message programmatically. The FollowUpOptions class includes the voting_buttons property, which can be used to set or retrieve the desired voting options.
In this article, we’ll explore a detailed example of how to create a MapiMessage with voting options to set up a poll effectively.
Create a Poll Using MapiMessage
To create a poll, use the voting_buttons property of the FollowUpOptions class as shown in the code sample below:
import aspose.email as ae
msg = ae.mapi.MapiMessage.load("my.msg")
# Set FollowUpOptions Buttons
options = ae.mapi.FollowUpOptions()
options.voting_buttons = "Yes;No;Maybe;Exactly!"
msg.save("voting_btns.msg")
Read Voting Options from MapiMessages
The following code snippet shows you how to read voting options from a MapiMessage.
Read Only Voting Buttons
To read only voting buttons, consider the following code snippet:
Add Voting Buttons to Existing Messages
The following code snippet shows you how to add voting button to an existing message:
Delete Voting Buttons from Messages
The following code snippet shows you how to delete a voting button from a message:
Read Voting Results Information
The following code snippet shows you how to read voting results information:
Retrieve Reaction Information from MSG
The get_reactions method of the FollowUpManager class allows you to retrieve the list of reactions left on a MAPI message, which makes it easy to analyze user engagement. Every item of the returned list is a UserReaction object exposing the name, email, type and reaction_date_time properties. The reaction kind is a value of the ReactionType enumeration: LIKE, HEART, CELEBRATE, LAUGH, SURPRISED, SAD or UNKNOWN.
The following code sample demonstrates how to retrieve the available reactions for a specified message:
from aspose.email.mapi import MapiMessage, FollowUpManager
# Load the message file
msg = MapiMessage.load("message.msg")
# Retrieve the list of reactions on the message
reactions = FollowUpManager.get_reactions(msg)
# Iterate through each reaction and output the details
for reaction in reactions:
print(f"User: {reaction.name}, Email: {reaction.email}, "
f"Reaction: {reaction.type}, Date: {reaction.reaction_date_time}")