Hi Team we encountered below issues in few of the PST Files which we tried to read via both Java and Dotnet.
Unread count shown is incorrect: The folder has a total of 6 mails only but the unread count property of FolderInfo object returns as 14 which is incorrect.
Folder Id: AAAAABtYvU3z03hPqxXXqIf29TiCgAAA
Attachment is not shown: The MapiMessage shows Has Attachment as true but when tried to get attachments the array is shown empty.
Message Id: AAAAABtYvU3z03hPqxXXqIf29TiEASAA
Incorrect message order when calling getContents for a folder: When tried to read a specific PST File and calling the folder.getContents() the messages are received in weird order and not based on the time, which for other files work properly.
Can you have them checked, I have attached the zip containing the PST file showing the issue mentioned above of 1 and 2. The 3rd issue’s PST file is a personal one and is a large file thus unable to share it.
It seems you are encountering several issues while parsing PST files using Aspose.Email. Let’s address each of your concerns:
Incorrect Unread Count: The unread count being reported as 14 when there are only 6 emails in the folder could be due to a few reasons, such as the presence of hidden or system messages that are not visible in the standard view. To troubleshoot this, you can use the PersonalStorageQueryBuilder to specifically query for unread messages and verify the count. Here’s a code snippet that demonstrates how to retrieve unread messages:
using Aspose.Email.Mapi;
using Aspose.Email.Storage.Pst;
// Load the PST file
using (PersonalStorage personalStorage = PersonalStorage.FromFile("path_to_your_pst_file.pst"))
{
FolderInfo folder = personalStorage.RootFolder.GetSubFolder("Inbox");
PersonalStorageQueryBuilder builder = new PersonalStorageQueryBuilder();
builder.HasNoFlags(MapiMessageFlags.MSGFLAG_READ);
MessageInfoCollection unreadMessages = folder.GetContents(builder.GetQuery());
Console.WriteLine("Unread messages count: " + unreadMessages.Count);
}
Attachments Not Shown: If the MapiMessage indicates that there are attachments but the array is empty, it could be due to the way the attachments are being accessed. Ensure that you are correctly retrieving the attachments from the MapiMessage object. Here’s an example of how to access attachments:
MapiMessage message = folder.GetContents().FirstOrDefault(); // Get the first message
if (message != null && message.HasAttachment)
{
foreach (var attachment in message.Attachments)
{
Console.WriteLine("Attachment Name: " + attachment.Name);
}
}
Incorrect Message Order: The order of messages when calling getContents() may vary based on how the messages are stored in the PST file. If the messages are not sorted by date, you can implement a sorting mechanism after retrieving the messages. For example, you can sort the messages based on their Date property:
var messages = folder.GetContents();
var sortedMessages = messages.OrderBy(m => m.Date).ToList();
If you continue to experience these issues, it may be beneficial to check the integrity of the PST file or consider reaching out to Aspose support for further assistance.
Feel free to share any additional details or specific error messages you encounter, and I would be happy to help further!
The unread query has been resolved on using the above said QueryBuilder logic, but the attachment issue and other 2 issues are not resolved. We cannot use sorting logic after fetching as we fetch based on the limit and it will not be the same always.
But the same when i try for another message id i get this: This got the fileName from getLongFileName() instead of getDisplayName() in above case getLongFileName() returns nil (AAAAABtYvU3z03hPqxXXqIf29ThEASAA)
You need to check an ObjectData attachment property.
The ObjectData refers to the PR_ATTACH_DATA_OBJ MAPI property, which contains an embedded object as an attachment.
This property is used when the attachment is an OLE object rather than a simple file or binary data.
It allows storing and retrieving complex objects, such as embedded documents or applications, within an email message.
The behavior you’re observing suggests the ordering of messages within folder.getContents() depends on how the PST file was structured when it was created or modified. Aspose.Email does not guarantee a specific order unless the underlying PST file maintains it.
@margarita.samodurova Okay, so you mean like the PST file has stored that mails in that order and thus is rendered in similar manner via folder.getContents() ?
Also I would like to know if we can do the search Based on the following using PersonalStorageQueryBuilder
1. Attachment Name
2. Attachment Type (File type like, png, jpg etc.)
3. Attachment Content
4. Is Inline Attachment
5. Email Content (Entire Message)
Also we found that no mails gets listed when we search using senders address getFrom
Yes, exactly. When you use folder.GetContents(), it retrieves the emails stored within that specific folder, preserving the order as maintained by the PST file.
Regarding the other questions, I will forward them to the developers, and they will review them on Monday.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.