How to maintain Read/Unread status of Messages while migrating from PST file to Office 365. Please share sample c# code.
thanks
How to maintain Read/Unread status of Messages while migrating from PST file to Office 365. Please share sample c# code.
thanks
I have shared sample code with you. This will help you to achieve your requirements.
MapiMessage msg = MapiMessage.FromFile(@“test.msg”);
if ((msg.Flags & MapiMessageFlags.MSGFLAG_READ) == MapiMessageFlags.MSGFLAG_READ) { //message is read }
thanks for your reply but you did not understand my question. I am able to check Read/Unread of Messages from PST File. But when i migrate these messages to Office 365 all the messages are Unread.
So please provide a solution to maintain Read /Unread Status after migrating into Office 365 with sample c# code.
Thanks
I have observed your requirements and request you to please provide the sample PST file along with used sample code and test account where you are exporting EML from PST. There are no specific settings when exporting message from PST to Office 365. Whatever status of email is in PST, the same will be in mail account.
Hi, Please find an office 365 account details and test pst file for the same. Please check and let us know the results.
Email Id: [ravi@mailshub.onmicrosoft.com](mailto:ravi@mailshub.onmicrosoft.com)
Password: Test@123
Test.zip (30.6 KB)
Thank you for sharing the information. As requested earlier, please also provide the used sample code reproducing the issue on your end.
Hi, this is the c# code i am using
foreach (MapiMessage message in PSTFolder.EnumerateMessages())
{
client.AppendMessage(client.MailboxInfo.InboxUri, message.ToMailMessage(new
MailConversionOptions { ConvertAsTnef = true }));
}
I suggest you to please try using following sample code on your end to serve the purpose.
public static void TestPSTMessageInfo()
{
String path = @"C:\Email\Test\";
using (var personalStorage = PersonalStorage.FromFile(path + "Test.pst"))
{
var client = GetExchangeEWSClient();
FolderInfo PSTFolder = personalStorage.RootFolder.GetSubFolder("Inbox");
foreach (MessageInfo messageingfo in PSTFolder.EnumerateMessages())
{
MapiMessage message= personalStorage.ExtractMessage(messageingfo);
String mess=client.AppendMessage(client.MailboxInfo.InboxUri, message.ToMailMessage(new
MailConversionOptions
{ ConvertAsTnef = true }));
if ((message.Flags & MapiMessageFlags.MSGFLAG_READ) == MapiMessageFlags.MSGFLAG_READ)
{
client.SetReadFlag(mess, true);
//message is read
}
}
}
}
Thank you so much for your reply. It worked !!!