MapiMessage Kullanarak Oylama Seçeneğiyle Çalışma

MapiMessage Kullanarak Oylama Seçeneği Oluşturma

Microsoft Outlook, kullanıcıların yeni bir mesaj oluştururken bir anket yapmalarına izin verir. Evet, Hayır, Belki gibi oylama seçenekleri ekleyebilirler. Aspose.Email, yeni bir Outlook mesajı oluştururken aynı işlevi sağlar. ___ FollowUpOptions class, şunları sağlar VotingButtons oylama seçeneklerinin değerini ayarlamak veya almak için kullanılabilecek özellik. Bu makale, bir ___ oluşturmanın detaylı örneğini sunar. MapiMessage anket oluşturmak için oylama seçenekleriyle.

MapiMessage Kullanarak Anket Oluşturma

Aşağıdaki kod parçacığı, bir anket oluşturmayı gösterir, ___ FollowUpManager sınıf, aşağıdaki kod parçacığında gösterildiği gibi kullanılabilir.

// 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’tan Oylama Seçeneklerini Okuma

Aşağıdaki kod parçacığı, bir ___‘dan Oylama Seçeneklerini Okumayı gösterir 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();

Sadece Oylama Düğmelerini Okuma

Aşağıdaki kod parçacığı, sadece oylama düğmelerini nasıl okuyacağınızı gösterir.

// 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);

Mevcut Mesaja Oylama Düğmesi Ekleme

Aşağıdaki kod parçacığı, mevcut bir mesaja oylama düğmesi eklemeyi gösterir.

// 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");

Bir Mesajdan Oylama Düğmesini Silme

Aşağıdaki kod parçacığı, bir mesajdan oy düğmesini nasıl sileceğinizi gösterir.

// 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");

Oy Sonuçları Bilgilerini Oku

Aşağıdaki kod parçacığı, oy sonuçları bilgilerini nasıl okuyacağınızı gösterir.

// 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();
}

Örneklerde Kullanılan Metodlar

Aşağıdaki kod parçacığı, örneklerde kullanılan bir örnek mesajı nasıl oluşturacağınızı gösterir.

// 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;
}