Oylama Seçenekleri Oluşturma ve Yönetme
Microsoft Outlook, kullanıcıların yeni bir e-posta oluştururken bir anket yapmasına izin verir; bu sayede Evet, Hayır, Belki gibi oylama seçenekleri ekleyebilirler. Benzer şekilde, Aspose.Email, programlı olarak yeni bir Outlook mesajı oluştururken anket oluşturma işlevselliği sağlar. FollowUpOptions sınıf, istenen oylama seçeneklerini ayarlamak veya almak için kullanılabilecek voting_buttons özelliğini içerir.
Bu makalede, nasıl bir şey oluşturulacağını ayrıntılı bir örnekle inceleyeceğiz: MapiMessage oylama seçenekleriyle bir anketi etkili bir şekilde kurun.
MapiMessage Kullanarak Anket Oluştur
Anket oluşturmak için, FollowUpOptions aşağıdaki kod örneğinde gösterildiği gibi sınıf:
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")
MapiMessage’lardan Oylama Seçeneklerini Oku
Aşağıdaki kod parçacığı, bir şeyden oylama seçeneklerini nasıl okuyacağınızı gösterir: 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)
Sadece Oylama Düğmelerini Oku
Sadece oylama düğmelerini okumak için aşağıdaki kod parçacığını göz önünde bulundurun:
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)
Mevcut Mesajlara Oylama Düğmeleri Ekle
Aşağıdaki kod parçacığı, mevcut bir mesaja oylama düğmesi eklemeyi gösterir:
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")
Mesajlardan Oylama Düğmelerini Sil
Aşağıdaki kod parçacığı, bir mesajdan oylama düğmesini silmeyi gösterir:
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")
Oylama Sonuçları Bilgisini Oku
Aşağıdaki kod parçacığı, oylama sonuçları bilgisini okumayı gösterir:
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’den Tepki Bilgilerini Al
Bu get_reactions metodu FollowUpManager sınıf, bir MAPI mesajına bırakılmış tepkileri almanıza olanak tanır; bu da kullanıcı etkileşimini analiz etmeyi kolaylaştırır. Döndürülen listedeki her öğe bir UserReaction nesne şunu sunar name, email, type ve reaction_date_time özellikler. Tepki türü şunun bir değeridir ReactionType enumerasyonu: LIKE, HEART, CELEBRATE, LAUGH, SURPRISED, SAD veya UNKNOWN.
Aşağıdaki kod örneği, belirtilen bir mesaj için mevcut tepkileri almaya nasıl yapılacağını gösterir:
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}")