MapiMessage का उपयोग करके मतदान विकल्प के साथ काम करना

MapiMessage का उपयोग करके मतदान विकल्प बनाना

Microsoft Outlook उपयोगकर्ताओं को नया संदेश लिखते समय एक पोल बनाने देता है। यह उन्हें हाँ, नहीं, शायद आदि जैसे मतदान विकल्प शामिल करने की सुविधा देता है। Aspose.Email नया Outlook संदेश बनाते समय वही अनुमति देता है। यह FollowUpOptions class प्रदान करता है VotingButtons प्रॉपर्टी जिसका उपयोग मतदान विकल्पों के मान को सेट या प्राप्त करने के लिए किया जा सकता है। यह लेख एक विस्तृत उदाहरण प्रदान करता है … बनाने का MapiMessage पोल बनाने के लिए मतदान विकल्पों के साथ।

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

निम्नलिखित कोड स्निपेट दिखाता है कि एक पोल कैसे बनाया जाए, FollowUpManager क्लास का उपयोग इस प्रकार किया जा सकता है जैसा कि नीचे कोड स्निपेट में दिखाया गया है।

// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-Java
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.setVotingButtons("Yes;No;Maybe;Exactly!");
client.send(message, options);

MapiMessage से मतदान विकल्प पढ़ना

निम्नलिखित कोड स्निपेट दिखाता है कि … से मतदान विकल्प कैसे पढ़ें। MapiMessage.

// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-Java
// The path to the File directory.
String fileName = "outlook/message.msg";

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.getVotingButtons();

केवल मतदान बटन पढ़ना

निम्नलिखित कोड स्निपेट दिखाता है कि केवल मतदान बटन कैसे पढ़े जाएँ।

// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-Java
InputStream ms = new FileInputStream(dataDir + "MapiMsgWithPoll_out.msg");
MapiMessage testMsg = MapiMessage.fromStream(ms);

// This method can be useful when it is necessary to read only voting buttons
// Voting buttons will be introduced as a collection of string values
IList buttons = FollowUpManager.getVotingButtons(testMsg);

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

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

// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-Java
// The path to the File directory.
String dataDir = "outlook/";

MapiMessage mapi = MapiMessage.fromFile(dataDir + "message.msg");
FollowUpManager.addVotingButton(mapi, "Indeed!");
mapi.save(dataDir + "AddVotingButtonToExistingMessage_out.msg");

संदेश से मतदान बटन हटाना

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

// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-Java
// The path to the File directory.
String dataDir = "outlook/";

// Create New Message and set FollowUpOptions, FollowUpManager properties
MapiMessage msg = createTestMessage(false);

FollowUpOptions options = new FollowUpOptions();
options.setVotingButtons("Yes;No;Maybe;Exactly!");
FollowUpManager.setOptions(msg, options);
msg.save(dataDir + "MapiMsgWithPoll.msg");
FollowUpManager.removeVotingButton(msg, "Exactly!"); // Deleting a single button OR
FollowUpManager.clearVotingButtons(msg); // Deleting all buttons from a MapiMessage
msg.save(dataDir + "MapiMsgWithPoll.msg");

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

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

// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-Java
// The path to the File directory.
String dataDir = "outlook/";

MapiMessage msg = MapiMessage.fromFile(dataDir + "AddVotingButtonToExistingMessage.msg");
for (MapiRecipient recipient : msg.getRecipients()) {
    System.out.println("Recipient: " + recipient.getDisplayName());

    // Get the PR_RECIPIENT_AUTORESPONSE_PROP_RESPONSE property
    System.out.println("Response: " + recipient.getProperties().get_Item(MapiPropertyTag.PR_RECIPIENT_AUTORESPONSE_PROP_RESPONSE).getString());

    // Get the PR_RECIPIENT_TRACKSTATUS_TIME property
    System.out.println("Response time: " + recipient.getProperties().get_Item(MapiPropertyTag.PR_RECIPIENT_TRACKSTATUS_TIME).getDateTime());

    System.out.println();
}

उदाहरणों में उपयोग किए गए नमूना विधियाँ

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

// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-Java
public static MapiMessage createTestMessage(boolean 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.getFlags() ^ MapiMessageFlags.MSGFLAG_UNSENT);
    }
    return msg;
}