Class PersonalStorageQueryBuilder
Contents
[
Hide
]PersonalStorageQueryBuilder class
Builds search queries for the messages and folders of a PST.
public sealed class PersonalStorageQueryBuilder : MailQueryBuilder
Constructors
| Name | Description |
|---|---|
| PersonalStorageQueryBuilder() | Initializes a new instance of the PersonalStorageQueryBuilder class. |
Properties
| Name | Description |
|---|---|
| Bcc { get; } | Gets the field that allows to find messages that contain the specified string in the envelope structure’s BCC field. |
| Body { get; } | Gets the field that allows to find messages that contain the specified string in the body of the message. |
| Cc { get; } | Gets the field that allows to find messages that contain the specified string in the envelope structure’s CC field. |
| ContainerClass { get; } | Gets the field to search folders by container class. |
| ContentsCount { get; } | Gets the field to search folders by the number of items they contain. |
| DefaultEncoding { get; } | Gets default encoding (charset) for query builder |
| FolderName { get; } | Gets the field to search folders by name. |
| From { get; } | Gets the field that allows to find messages that contain the specified string in the envelope structure’s FROM field. |
| Importance { get; } | Gets the field to search messages by importance. |
| InternalDate { get; } | Gets the field that allows to find messages by internal date. |
| MessageClass { get; } | Gets the field to search messages by message class. |
| MessageId { get; } | Gets the field to search messages by the Message-ID header. |
| MessageSize { get; } | Gets the field to search messages by size, in bytes. |
| OnlyFoldersCreatedByUser { get; } | Gets the field to search only the folders created by the user, leaving out the standard Outlook folders. |
| SentDate { get; } | Gets the field that allows to find messages by sent date. |
| Subject { get; } | Gets the field that allows to find messages that contain the specified string in the envelope structure’s SUBJECT field. |
| Text { get; } | Gets the field that allows to find the messages that contain the specified string in the headers (subject, from, to, cc) and body of the message. |
| To { get; } | Gets the field that allows to find messages that contain the specified string in the envelope structure’s TO field. |
| UnreadContentsCount { get; } | Gets the field to search folders by the number of unread items they contain. |
Methods
| Name | Description |
|---|---|
| FindConversationThread(MessageInfo) | Adds a condition that finds the messages of the same conversation as the specified message. |
| GetQuery() | Gets the query. |
| HasFlags(MapiMessageFlags) | Adds a condition that finds messages with the specified flags set. |
| HasNoFlags(MapiMessageFlags) | Adds a condition that finds messages with the specified flags not set. |
| HasNoSubfolders() | Adds a condition that finds folders without subfolders. |
| HasSubfolders() | Adds a condition that finds folders with subfolders. |
| Or(MailQuery, MailQuery) | Search messages that match either search key. Provides disjunction between two expressions (OR). |
Remarks
Add conditions through the fields of the builder: for messages, the fields inherited from MailQueryBuilder, such as From or Subject, and fields such as MessageClass; for folders, FolderName, ContentsCount and the like. All conditions are combined. Pass the result of GetQuery to FolderInfo.GetContents or FolderInfo.GetSubFolders.
Examples
This example finds the unread messages of the Inbox from a given sender whose subject contains “invoice”.
[C#]
using (var pst = PersonalStorage.FromFile("archive.pst"))
{
var inbox = pst.GetPredefinedFolder(StandardIpmFolder.Inbox);
var builder = new PersonalStorageQueryBuilder();
builder.From.Contains("billing@example.com");
builder.Subject.Contains("invoice", true);
builder.HasNoFlags(MapiMessageFlags.MSGFLAG_READ);
foreach (var messageInfo in inbox.GetContents(builder.GetQuery()))
{
Console.WriteLine(messageInfo.Subject);
}
}
[Visual Basic]
Using pst As PersonalStorage = PersonalStorage.FromFile("archive.pst")
Dim inbox As FolderInfo = pst.GetPredefinedFolder(StandardIpmFolder.Inbox)
Dim builder As New PersonalStorageQueryBuilder()
builder.From.Contains("billing@example.com")
builder.Subject.Contains("invoice", True)
builder.HasNoFlags(MapiMessageFlags.MSGFLAG_READ)
For Each messageInfo As MessageInfo In inbox.GetContents(builder.GetQuery())
Console.WriteLine(messageInfo.Subject)
Next
End Using
See Also
- class MailQueryBuilder
- namespace Aspose.Email.Storage.Pst
- assembly Aspose.Email