MSG에서 투표 옵션 및 반응 작업

MapiMessage로 투표 옵션 만들기

Microsoft Outlook은 새 이메일을 작성할 때 설문을 만들 수 있는 기능을 제공하여 사용자가 예, 아니오, 아마도 등과 같은 투표 옵션을 포함하도록 합니다. Aspose.Email은 프로그래밍 방식으로 새 Outlook 메시지를 생성할 때 유사한 기능을 제공합니다. 해당 FollowUpOptions class는 다음을 제공합니다 VotingButtons 투표 옵션을 설정하거나 가져오는 데 사용할 수 있는 속성입니다. MapiMessage Aspose.Email 네임스페이스 내에서 Microsoft Outlook에서 일반적으로 사용되는 메시징 애플리케이션 프로그래밍 인터페이스(MAPI) 형식의 이메일 메시지를 나타내는 클래스를 말합니다. MapiMessage 클래스를 사용하면 개발자가 이메일에 설문 버튼을 추가할 수 있습니다. 이 문서에서는 투표 옵션이 포함된 MapiMessage를 생성하여 설문을 만드는 자세한 예제를 제공합니다.

설문 만들기

다음 코드 스니펫은 Aspose.Email을 사용하여 Outlook 메시지에서 설문 조사를 만드는 방법을 보여줍니다. 해당 FollowUpManager 클래스는 투표 옵션 설정을 용이하게 합니다.

// Create a MapiMessage with the sender, recipient, subject, and body
var 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..."
);

// Create FollowUpOptions and set the voting buttons
var options = new FollowUpOptions
{
    VotingButtons = "Yes;No;Maybe;Exactly!"
};

// Apply the follow-up options to the message
FollowUpManager.SetOptions(msg, options);
  • FollowUpOptions: 투표 버튼과 같은 후속 작업을 구성하는 속성을 제공합니다.
  • VotingButtons: 다양한 투표 옵션이 세미콜론으로 구분된 문자열 속성.
  • FollowUpManager.SetOptions: 지정된 후속 옵션을 메시지에 적용합니다.

투표 옵션 읽기

투표 옵션을 가져오려면 MapiMessage, 다음을 사용할 수 있습니다 GetOptions 메서드. 이 메서드는 투표 버튼을 검색할 뿐만 아니라 필요에 따라 카테고리와 같은 추가 매개변수도 제공할 수 있습니다.

// Retrieve follow-up options from the message
var options = FollowUpManager.GetOptions(msg);

// Voting buttons are returned as a string with a semicolon separator
string votingButtons = options.VotingButtons;

// Display the voting buttons
Console.WriteLine($"Voting Options: {votingButtons}");
  • GetOptions: 다음을 검색합니다 FollowUpOptions 메시지에서 가져온 객체로, 투표 버튼 및 기타 속성을 포함할 수 있습니다.
  • VotingButtons: 옵션이 세미콜론으로 구분된 문자열로 추출되어 쉽게 표시하거나 조작할 수 있습니다.

투표 버튼 읽기

투표 버튼을 개별 문자열 리스트로만 접근해야 하면 다음을 사용할 수 있습니다 GetVotingButtons 메서드로, 컬렉션 형태로 반환합니다.

// Read only voting buttons as a collection of string values
var votingButtons = FollowUpManager.GetVotingButtons(msg);

// Display each voting button
foreach (var button in votingButtons)
{
    Console.WriteLine($"Voting Button: {button}");
}
  • GetVotingButtons: 투표 버튼 문자열 컬렉션을 반환하여 반복 및 표시·수정과 같은 작업에 편리합니다.

투표 버튼 추가

기존 메시지에 추가 투표 버튼을 다음을 사용하여 추가할 수 있습니다 AddVotingButton 메서드. 이는 투표 옵션을 동적으로 업데이트하는 데 유용합니다.

// Add a new voting button to the existing message
FollowUpManager.AddVotingButton(msg, "Indeed!");
  • AddVotingButton: 메시지에 기존 투표 버튼에 새 투표 옵션을 추가하여 설문을 동적으로 맞춤 설정할 수 있습니다.

투표 버튼 삭제

특정 투표 버튼을 제거하거나 메시지의 모든 버튼을 초기화하려고 할 수 있습니다. 다음 코드는 이를 사용하여 두 작업을 모두 보여줍니다 RemoveVotingButtonClearVotingButtons 메서드들.

// Delete a specific voting button
FollowUpManager.RemoveVotingButton(msg, "Exactly!");

// Or delete all voting buttons from the MapiMessage
FollowUpManager.ClearVotingButtons(msg);

투표 결과 읽기

Aspose.Email은 메시지 수신자의 투표 결과를 읽을 수도 있습니다. 수신자의 응답 및 응답 시간과 같은 속성에 접근할 수 있습니다.

// Load a MapiMessage from a file
var msg = MapiMessage.Load("sample.msg");

// Iterate through each recipient and display their vote information
foreach (var recipient in msg.Recipients)
{
    Console.WriteLine($"Recipient: {recipient.DisplayName}");

    // Get the recipient's response using the appropriate MapiPropertyTag
    var response = recipient.Properties[MapiPropertyTag.PR_RECIPIENT_AUTORESPONSE_PROP_RESPONSE].GetString();
    Console.WriteLine($"Response: {response}");

    // Get the response time
    var responseTime = recipient.Properties[MapiPropertyTag.PR_RECIPIENT_TRACKSTATUS_TIME].GetDateTime();
    Console.WriteLine($"Response time: {responseTime}\n");
}

MSG에서 반응 정보 가져오기

다음은 GetReactions 메서드 FollowUpManager 클래스를 사용하면 MAPI 메시지에 대한 반응 목록을 가져올 수 있어 사용자 참여를 분석하기 쉽습니다. 다음 코드 샘플은 지정된 메시지에 대한 사용 가능한 반응을 가져와 사용자 상호 작용에 대한 인사이트를 제공하는 방법을 보여줍니다.

// Load the message file
var msg = MapiMessage.Load(fileName);

// Retrieve the list of reactions on the message
var reactions = FollowUpManager.GetReactions(msg);

// Iterate through each reaction and output the details to the console
foreach (var reaction in reactions)
{
    Console.WriteLine($"User: {reaction.Name}, Email: {reaction.Email}, Reaction: {reaction.Type}, Date: {reaction.ReactionDateTime}");
}