Get Inbox to show new messages

Topics: Help requests
Sep 18, 2015 at 11:53 PM
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 7: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.

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

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

best way to retrieve new messages is to use the idle functionality. You can find the sample code here: https://imapx.codeplex.com/wikipage?title=Idle%20support&referringTitle=Documentation

Greets,

Pavel
Oct 8, 2015 at 9:40 PM
VB CODE:
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)
    Next
    RefreshMailFoldersComplete(eAcc.MailAdress)
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
VB CODE:
Private Sub PreviewImapMessage(ByVal mess As ImapX.Message)
    'mess.Download(MessageFetchMode.Full)
    '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
    Next
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 11:27 AM
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.