वोटिंग विकल्प बनाना और प्रबंधित करना

Microsoft Outlook उपयोगकर्ताओं को नया ईमेल बनाते समय पोल बनाने की सुविधा देता है, जिससे वे Yes, No, Maybe आदि जैसे वोटिंग विकल्प शामिल कर सकते हैं। इसी तरह, Aspose.Email प्रोग्रामेटिक रूप से नया Outlook संदेश बनाते समय पोल बनाने की कार्यक्षमता प्रदान करता है। The FollowUpOptions क्लास में voting_buttons प्रॉपर्टी शामिल है, जिसका उपयोग वांछित वोटिंग विकल्प सेट या प्राप्त करने के लिए किया जा सकता है।

इस लेख में, हम एक विस्तृत उदाहरण के माध्यम से यह जानेंगे कि कैसे बनाया जाए MapiMessage वोटिंग विकल्पों के साथ प्रभावी रूप से पोल सेट करने के लिए।

MapiMessage का उपयोग करके पोल बनाएं

पोल बनाने के लिए, इस क्लास की voting_buttons प्रॉपर्टी का प्रयोग करें FollowUpOptions क्लास, जैसा कि नीचे दिए गए कोड नमूने में दिखाया गया है:

import aspose.email as ae

eml = ae.MailMessage("from@domain.com", "to@domain.com", "Poll", "Please vote")
msg = ae.mapi.MapiMessage.from_mail_message(eml)

# Set the voting buttons
options = ae.mapi.FollowUpOptions()
options.voting_buttons = "Yes;No;Maybe;Exactly!"
ae.mapi.FollowUpManager.set_options(msg, options)

msg.save("voting_btns.msg")

MapiMessages से वोटिंग विकल्प पढ़ें

निम्नलिखित कोड स्निपेट दर्शाता है कि एक MapiMessage.

from aspose.email.mapi import MapiMessage, FollowUpManager

message = MapiMessage.load(data_dir + "voting_btns.msg")

# This method is useful when, besides the voting buttons, other parameters
# (a category, for example) have to be read as well
options = FollowUpManager.get_options(message)

# The voting buttons are returned as a single string with a semicolon as a separator
print(options.voting_buttons)

केवल वोटिंग बटन पढ़ें

केवल वोटिंग बटन पढ़ने के लिए, निम्नलिखित कोड स्निपेट पर विचार करें:

from aspose.email.mapi import MapiMessage, FollowUpManager

message = MapiMessage.load(data_dir + "voting_btns.msg")

buttons = FollowUpManager.get_voting_buttons(message)
for button in buttons:
    print(button)

मौजूदा संदेशों में वोटिंग बटन जोड़ें

निम्न कोड स्निपेट दिखाता है कि कैसे एक मौजूदा संदेश में मतदान बटन जोड़ें:

from aspose.email.mapi import MapiMessage, FollowUpManager

message = MapiMessage.load(data_dir + "message.msg")

FollowUpManager.add_voting_button(message, "Indeed!")

message.save(data_dir + "AddVotingButtonToExistingMessage_out.msg")

संदेशों से वोटिंग बटन हटाएँ

निम्नलिखित कोड स्निपेट दर्शाता है कि संदेश से वोटिंग बटन कैसे हटाया जाए:

from aspose.email.mapi import MapiMessage, FollowUpManager

message = MapiMessage.load(data_dir + "voting_btns.msg")

# Delete a single button
FollowUpManager.remove_voting_button(message, "Exactly!")

# Or delete all the buttons of the message
FollowUpManager.clear_voting_buttons(message)

message.save(data_dir + "MapiMsgWithoutPoll_out.msg")

वोटिंग परिणाम जानकारी पढ़ें

निम्नलिखित कोड स्निपेट दर्शाता है कि वोटिंग परिणाम जानकारी कैसे पढ़ी जाए:

from aspose.email.mapi import MapiMessage, MapiPropertyTag

msg = MapiMessage.load(data_dir + "voting_btns.msg")

for recipient in msg.recipients:
    print(f"Recipient: {recipient.display_name}")

    # Get the PR_RECIPIENT_AUTORESPONSE_PROP_RESPONSE property
    if recipient.properties.contains_key(MapiPropertyTag.RECIPIENT_AUTORESPONSE_PROP_RESPONSE):
        response = recipient.properties[MapiPropertyTag.RECIPIENT_AUTORESPONSE_PROP_RESPONSE]
        print(f"Response: {response.get_string()}")

    # Get the PR_RECIPIENT_TRACKSTATUS_TIME property
    if recipient.properties.contains_key(MapiPropertyTag.RECIPIENT_TRACKSTATUS_TIME):
        response_time = recipient.properties[MapiPropertyTag.RECIPIENT_TRACKSTATUS_TIME]
        print(f"Response time: {response_time.get_date_time()}")

MSG से प्रतिक्रिया जानकारी प्राप्त करें

यह get_reactions विधि FollowUpManager क्लास आपको MAPI संदेश पर छोड़ी गई प्रतिक्रियाओं की सूची प्राप्त करने की अनुमति देती है, जिससे उपयोगकर्ता सहभागिता का विश्लेषण आसान हो जाता है। लौटाई गई सूची की प्रत्येक वस्तु एक UserReaction ऑब्जेक्ट जो उजागर करता है name, email, type और reaction_date_time गुणधर्म। प्रतिक्रिया प्रकार का मान है ReactionType इनोमरेशन: LIKE, HEART, CELEBRATE, LAUGH, SURPRISED, SAD या UNKNOWN.

निम्नलिखित कोड नमूना दिखाता है कि निर्दिष्ट संदेश के लिए उपलब्ध प्रतिक्रियाएँ कैसे प्राप्त की जाएँ:

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}")