Working with Follow Up and Due Date for Outlook MSG Files in C++

Setting Follow Up and Due Date for Outlook MSG Files

A follow up flag marks an email message for some kind of action. Microsoft Outlook lets users flag messages and, in the flag set-up, assign a due date for the follow up. Microsoft Outlook sends a reminder to the recipient to prompt them to follow up the email. Flagging emails and setting due dates programmatically lets software developers automate certain types of emails and help recipients remember to take action. For example, it could be used to send monthly messages to a sales team to remind them to complete their reports; or to send a message to all staff to remind them of a company meeting. Aspose.Email for C++ supports setting follow up flag and due date for the MapiMessage objects using FollowUpManager and FollowUpOptions. There are a number of variants in which the follow up flag can be set on a message. They are all used in the code sample below:

  1. Set a follow up flag for a message
  2. Add a due date and reminder date to a message
  3. Add a flag to a recipient’s message.
  4. Mark as complete.
  5. Remove flag.
  6. Read follow up options.

Setting a FollowUp flag

The following code snippet shows you how to set a followUp flag using C++ Email Parser Library API.

For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Email-for-C
// The path to the File directory.
System::String dataDir = RunExamples::GetDataDir_Outlook();
System::SharedPtr<MailMessage> mailMsg = System::MakeObject<MailMessage>();
mailMsg->set_Sender(L"AETest12@gmail.com");
mailMsg->set_To(L"receiver@gmail.com");
mailMsg->set_Body(L"This message will test if follow up options can be added to a new mapi message.");
System::SharedPtr<MapiMessage> mapi = MapiMessage::FromMailMessage(mailMsg);
System::DateTime dtStartDate(2013, 5, 23, 14, 40, 0);
System::DateTime dtReminderDate(2013, 5, 23, 16, 40, 0);
System::DateTime dtDueDate = dtReminderDate.AddDays(1);
System::SharedPtr<FollowUpOptions> options = System::MakeObject<FollowUpOptions>(L"Follow Up", dtStartDate, dtDueDate, dtReminderDate);
FollowUpManager::SetOptions(mapi, options);
mapi->Save(dataDir + L"SetFollowUpflag_out.msg");

Setting Follow Up for Recipients

The following code snippet shows you how to set follow Up for recipients.

For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Email-for-C
// The path to the File directory.
System::String dataDir = RunExamples::GetDataDir_Outlook();
System::SharedPtr<MailMessage> mailMsg = System::MakeObject<MailMessage>();
mailMsg->set_Sender(L"AETest12@gmail.com");
mailMsg->set_To(L"receiver@gmail.com");
mailMsg->set_Body(L"This message will test if follow up options can be added to a new mapi message.");
System::SharedPtr<MapiMessage> mapi = MapiMessage::FromMailMessage(mailMsg);
mapi->SetMessageFlags(Aspose::Email::Outlook::MapiMessageFlags::MSGFLAG_UNSENT);
// Mark this message as draft
System::DateTime dtReminderDate(2013, 5, 23, 16, 40, 0);
// Add the follow up flag for receipient now
FollowUpManager::SetFlagForRecipients(mapi, L"Follow up", dtReminderDate);
mapi->Save(dataDir + L"SetFollowUpForRecipients_out.msg");

Marking a FollowUp flag as Completed

The following code snippet shows you how to mark followUp flag as completed.

For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Email-for-C
// The path to the File directory.
System::String dataDir = RunExamples::GetDataDir_Outlook();
System::SharedPtr<MapiMessage> mapiMessage = MapiMessage::FromFile(dataDir + L"Message.msg");
FollowUpManager::MarkAsCompleted(mapiMessage);
mapiMessage->Save(dataDir + L"MarkedCompleted_out.msg");

Removing a FollowUp flag

The following code snippet shows you how to remove followUp flag.

For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Email-for-C
// The path to the File directory.
System::String dataDir = RunExamples::GetDataDir_Outlook();
// Load file from Disk
System::SharedPtr<MapiMessage> mapi = MapiMessage::FromFile(dataDir + L"message.msg");
FollowUpManager::ClearFlag(mapi);
mapi->Save(dataDir + L"RemoveFollowUpflag_out.msg");

Read followup flag options for a message

The following code snippet shows you how to read followup flag options for a message.

For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Email-for-C
// The path to the File directory.
System::String dataDir = RunExamples::GetDataDir_Outlook();
System::SharedPtr<MapiMessage> mapi = MapiMessage::FromFile(dataDir + L"message.msg");
System::SharedPtr<FollowUpOptions> options = FollowUpManager::GetOptions(mapi);