کار با گزینه رأیگیری با استفاده از MapiMessage
ایجاد گزینه رأیگیری با استفاده از MapiMessage
Microsoft Outlook به کاربران اجازه میدهد هنگام ایجاد یک پیام جدید یک نظرسنجی ایجاد کنند. این امکان را میدهد تا گزینههای رأیگیری مانند بله، خیر، شاید و غیره را شامل شوند. Aspose.Email همین قابلیت را هنگام ایجاد یک پیام Outlook جدید فراهم میکند. این FollowUpOptions کلاس فراهم میکند 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;
}