Nasıl yapılır: Belirli Klasör İçinde Program Aracılığıyla Arama Yapma
Bu kod örneğinde Find ve FindNext yöntemleri, Gelen Kutusu içindeki e-posta iletilerinin konu alanında metin aramak için kullanılır. Bu yöntemde T harfiyle başlayan Subject metnini denetlemek için dize filtresi kullanılır.
Uygulama hedefi: Bu konudaki bilgiler, Outlook 2013 ve Outlook 2010 için uygulama düzeyi projelere yöneliktir. Daha fazla bilgi edinmek için, bkz. Office Uygulaması ve Proje Türüne Göre Kullanılabilir Özellikler.
Örnek
Private Sub SearchInBox()
Dim inbox As Outlook.MAPIFolder = Me.Application.ActiveExplorer().Session. _
GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
Dim items As Outlook.Items = inbox.Items
Dim mailItem As Outlook.MailItem = Nothing
Dim folderItem As Object
Dim subjectName As String = String.Empty
Dim filter As String = "[Subject] > 's' And [Subject] <'u'"
folderItem = items.Find(filter)
While (folderItem IsNot Nothing)
mailItem = TryCast(folderItem, Outlook.MailItem)
If mailItem IsNot Nothing Then
subjectName = vbCrLf & mailItem.Subject
End If
folderItem = items.FindNext()
End While
subjectName = "The following e-mail messages were found: " _
& subjectName
MsgBox(subjectName)
End Sub
private void SearchInBox()
{
Outlook.MAPIFolder inbox = this.Application.ActiveExplorer().Session.
GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.Items items = inbox.Items;
Outlook.MailItem mailItem = null;
object folderItem;
string subjectName = string.Empty;
string filter = "[Subject] > 's' And [Subject] <'u'";
folderItem = items.Find(filter);
while (folderItem != null)
{
mailItem = folderItem as Outlook.MailItem;
if (mailItem != null)
{
subjectName += "\n" + mailItem.Subject;
}
folderItem = items.FindNext();
}
subjectName = " The following e-mail messages were found: " +
subjectName;
MessageBox.Show(subjectName);
}
Ayrıca bkz.
Görevler
Nasıl yapılır: Program Aracılığıyla Klasörü Ada Göre Alma