This project is read-only.

Get Inbox to show new messages

Topics: Help requests
Sep 19, 2015 at 12:53 AM
I iterate through inbox messages, see below, to populate messages to a listview
~~~~~~~~~~~VB CODE~~~~~~~~~~~
                Dim nodeI As Integer = TreeView.SelectedNode.Index
                For Each mess In Client.Folders.Item(nodeI).Messages
~~~~~~~~~~~VB CODE~~~~~~~~~~~
This Works well.

After receiving a New Message, if click again on the inbox folder in the treeView which repopulates the listview the New Message does not appear. However, if I click(this is for the first time) all messages or important, the New Message is present.

I considered trying "client.SendAndReceive()" to refresh the inbox; I'm not sure to use function or even if it is the right way to get the INBOX to refresh.
Sep 19, 2015 at 8:20 AM
I created a refresh button that in part executes the below code, and subsequently repopulates the listview. New messages do show up after using refresh button. I plan to get this working with Idle, OnNewMessagesArrived event.

   For Each imapFolder In Client.Folders
        imapFolder.Messages.Download(, MessageFetchMode.Minimal)
Is this the best way to do this?

What is "client.SendAndReceive()" for? How do I implement it?
Oct 8, 2015 at 2:04 PM

best way to retrieve new messages is to use the idle functionality. You can find the sample code here:


Oct 8, 2015 at 10:40 PM
Private Sub RefreshMailFolders(ByVal eAcc As EmailAccount)   '######## RefreshMailFolders '########
    Dim imapFolder As ImapX.Folder
    On Error Resume Next
    For Each imapFolder In eAcc.IMAP.Folders
        imapFolder.Messages.Download(, MessageFetchMode.Minimal)
End Sub
I have disabled the above code as a method for checking for new messages I will attempt to get idle functionality working.

Despite this change, I am still getting blank messages(bodies) under the following circumstances:

1) I view some but not all messages from the INBOX
Private Sub PreviewImapMessage(ByVal mess As ImapX.Message)
    'set WebBrowser DocumentText 
    wbMail.DocumentText = If(mess.Body.HasHtml, mess.Body.Html, mess.Body.Text)
    'Headers in label
    Dim i As Integer = 0
    Dim Header As Object
    For Each Header In mess.Headers
        LabelHeaders.Text = LabelHeaders.Text & " " & mess.Headers.Item(mess.Headers.Keys(i))
        i = i + 1
End Sub
2) I view messages from any folder other then INBOX , then return to view previously unseen messages from INBOX

3) Some of these messages will be blank, If instead I close app and restart app and just attempt to view only messages from INBOX all messages will have their bodies.
Oct 10, 2015 at 12:27 PM
I have stoped useing AutoPopulateFolderMessages and AutoDownloadBodyOnAccess, and instead I'm downloading the folder contents for a given folder just before it is populated to a listview. Things seem to be working now.