Before I decide to purchase Limilabs IMAP Mail library, I need to ensure it works.
I have been unable to successfully search through my email for words contained in the Subject field of my email stored on my provider.
I have tried various things, none of which seem to work.
The code I have written (VB.Net) follows. The search on Flag.all works fine, but if I place a text value in the form field "txtSubject"
the search does not find anything. Any ideas?
Using imap As New Imap
imap.Connect(My.Settings.MailServer) ' or ConnectSSL for SSL
imap.UseBestLogin(My.Settings.UserName, My.Settings.Password)
imap.SelectInbox()
If txtSubject.Text.Trim.Length > 0 Then
query.Subject = txtSubject.Text.Trim
oList = imap.Search(query)
Else
oList = imap.Search((Flag.All))
End If
Dim lvi As ListViewItem = Nothing
For Each uid As Long In oList
Dim email As IMail = New _
MailBuilder().CreateFromEml(imap.GetMessageByUID(uid))
lvi = lvMail.Items.Add(uid.ToString.Trim)
lvi.SubItems.Add(email.Subject.ToString.Trim)
lvi.SubItems.Add(email.[Date].ToString)
lvi.SubItems.Add(email.From.ToString.Trim)
'set all columns to auto-resize
lvMail.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent)
'keep the listview scrolling during retrieval
lvMail.TopItem = lvi
lvMail.EnsureVisible(lvMail.Items.Count - 1)
'allow outside processes to keep going (no hogging!)
Application.DoEvents()
Next
imap.Close()
End Using