static void Main(
string[] args)
{
var license3 =
new Aspose.Email.License();
license3.SetLicense(“Aspose.Email.lic”);
AddMessageToInbox();
UpdatePstMessages();
Console.WriteLine(“Press any key to
continue…”);
Console.ReadKey();
}
static private void AddMessagsToInbox()
{
if (File.Exists(@“TestInbox.pst”))
{
File.Delete(@“TestInbox.pst”);
}
PersonalStorage pst = PersonalStorage.Create(“TestInbox.pst”, FileFormatVersion.Unicode);
pst.CreatePredefinedFolder(“Inbox”, StandardIpmFolder.Inbox);
pst.RootFolder.AddSubFolder(“TestFolder”);
MapiMessage msg =
new MapiMessage(
"newcustomeronnet@gmail.com",
"newcustomeronnet1@gmail.com", “Test Subject”, “Test Body”);
FolderInfo infoInbox = pst.GetPredefinedFolder(StandardIpmFolder.Inbox);
for (
int iCount = 0; iCount <= 100; iCount++)
{
msg.Subject = “Test Subject-” + iCount;
msg.SetBodyContent(“Test Body-” + iCount, BodyContentType.PlainText);
msg.SetMessageFlags(~MapiMessageFlags.MSGFLAG_READ);
infoInbox.AddMessage(msg);
}
}
static private void UpdatePstMessages()
{
PersonalStorage pst = PersonalStorage.FromFile(“TestInbox.pst”,
true);
FolderInfo infoInbox = pst.GetPredefinedFolder(StandardIpmFolder.Inbox);
FolderInfo infoTestFolder = pst.RootFolder.GetSubFolder(“TestFolder”);
List mapiMsgs =
new List();
MessageInfoCollection messageInfoCollection = infoInbox.GetContents(10,100);
foreach (MessageInfo messageInfo
in messageInfoCollection)
{
MapiMessage mapi = pst.ExtractMessage(messageInfo);
bool isread = (mapi.Flags & MapiMessageFlags.MSGFLAG_READ) == MapiMessageFlags.MSGFLAG_READ;
if (!isread)
{
infoInbox.DeleteChildItem(messageInfo.EntryId);
mapi.SetMessageFlags(MapiMessageFlags.MSGFLAG_READ);
mapiMsgs.Add(mapi);
}
}
pst.Dispose();
pst = PersonalStorage.FromFile(“TestInbox.pst”,
true);
infoTestFolder = pst.RootFolder.GetSubFolder(“TestFolder”);
foreach (MapiMessage mapiMsg
in mapiMsgs)
{
infoTestFolder.AddMessage(mapiMsg);
}
}
Please feel free to write us back if you have any other query in this regard.