/
SearchStringInPSTWithIgnoreCaseParameter.cs
51 lines (42 loc) · 2.01 KB
/
SearchStringInPSTWithIgnoreCaseParameter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using Aspose.Email.Mime;
using Aspose.Email.Mapi;
using Aspose.Email.Storage.Pst;
using System.IO;
using Aspose.Email.Tools.Search;
/*
This project uses Automatic Package Restore feature of NuGet to resolve Aspose.Email for .NET API reference
when the project is build. Please check https://Docs.nuget.org/consume/nuget-faq for more information.
If you do not wish to use NuGet, you can manually download Aspose.Email for .NET API from https://www.nuget.org/packages/Aspose.Email/,
install it and then add its reference to this project. For any issues, questions or suggestions
please feel free to contact us using https://forum.aspose.com/c/email
*/
namespace Aspose.Email.Examples.CSharp.Email.Outlook
{
class SearchStringInPSTWithIgnoreCaseParameter
{
public static void Run()
{
// The path to the File directory.
// ExStart:SearchStringInPSTWithIgnoreCaseParameter
string dataDir = RunExamples.GetDataDir_Outlook();
string path = dataDir + "SearchStringInPSTWithIgnoreCaseParameter_out.pst";
if (File.Exists(path))
{
File.Delete(path);
}
using (PersonalStorage personalStorage = PersonalStorage.Create(dataDir + "SearchStringInPSTWithIgnoreCaseParameter_out.pst", FileFormatVersion.Unicode))
{
FolderInfo folderInfo = personalStorage.CreatePredefinedFolder("Inbox", StandardIpmFolder.Inbox);
folderInfo.AddMessage(MapiMessage.FromMailMessage(MailMessage.Load(dataDir + "Message.eml")));
PersonalStorageQueryBuilder builder = new PersonalStorageQueryBuilder();
// IgnoreCase is True
builder.From.Contains("automated", true);
MailQuery query = builder.GetQuery();
MessageInfoCollection coll = folderInfo.GetContents(query);
Console.WriteLine(coll.Count);
}
// ExEnd:SearchStringInPSTWithIgnoreCaseParameter
}
}
}