Hi,
As I cycle through emails in the inbox and bring them into a datagridview I would like to bold font any that are unread, but cant find a property to represent this.
Something like:
if email = unread then set row in datagridview to bold. (code below)
I am happy with how to do the .NET part, just need to identify the unread ones.
I am using imap.PeekMessageByUID and only marking messages as read once opened locally.
Thanks,
Dave
Using imap As New Imap
Dim mAttachmentCount As String = ""
Dim mEmailFound As Boolean = False
Dim mEMailFrom(2) As String
Dim mEmailTo(2) As String
imap.Connect("mail@mail.com")
imap.UseBestLogin("fred@mail.com", "password")
imap.SelectInbox()
For Each uid As String In imap.GetAll()
Dim email As IMail = New MailBuilder().CreateFromEml(
imap.PeekMessageByUID(uid))
For Each mRow As DataGridViewRow In DataGridView1.Rows
If mRow.Cells("UID").Value = uid Then
mEmailFound = True
End If
Next
If mEmailFound = False Then 'Add the email
mEMailFrom = Split(email.From.ToString, "Address=")
mEMailFrom(0) = Replace(mEMailFrom(0), "Name=", "")
mEMailFrom(0) = Replace(mEMailFrom(0), "'", "")
mEMailFrom(1) = Replace(mEMailFrom(1), "'", "")
mEmailTo = Split(email.To.ToString, "Address=")
mEmailTo(0) = Replace(mEmailTo(0), "Name=", "")
mEmailTo(0) = Replace(mEmailTo(0), "'", "")
mEmailTo(1) = Replace(mEmailTo(1), "'", "")
mAttachmentCount = email.Attachments.ToString
mAttachmentCount = Replace(mAttachmentCount,
"Count = ", "")
DataGridView1.Rows.Add(email.Date,
mEMailFrom(0),
mEMailFrom(1),
mEmailTo(0),
mEmailTo(1),
email.Subject,
email.Text,
mAttachmentCount,
uid)
End If
Next
imap.Close()
End Using