The Mailparser retrieves messages from the mail server out of sequence, according to the order of MessageId as listed in the log.
I don’t know if this is something that can be resolved in Mailparser, or if it is a characteristic of the mail server as to how it indexes messages.
This anomaly becomes a problem when deleting messages from the server, as message two and three are in reverse order. What I see as message two is actually message three, and message three is actually message two. Any deletion I make is made using the numbered order of the messages as displayed in the app. The anomaly occurs solely with these two messages.
This is the Log:
This is my code:
Would someone with a better understanding of how mail servers work comment on this. Is this normal behavior? Is there some means of compensating for this when retrieving messages? Any enlightenment will be greatly appreciated.
Best regards
I don’t know if this is something that can be resolved in Mailparser, or if it is a characteristic of the mail server as to how it indexes messages.
This anomaly becomes a problem when deleting messages from the server, as message two and three are in reverse order. What I see as message two is actually message three, and message three is actually message two. Any deletion I make is made using the numbered order of the messages as displayed in the app. The anomaly occurs solely with these two messages.
This is the Log:
B4X:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Success=true, NumberOfMessages=11, TotalSize=58505
Messages.Size = 11
MessageID = 1
MessageID = 3
MessageID = 2
MessageID = 4
MessageID = 5
MessageID = 6
MessageID = 7
MessageID = 8
MessageID = 9
MessageID = 10
MessageID = 11
** Activity (main) Pause, UserClosed = true **
This is my code:
B4X:
Sub Activity_Create(FirstTime AsBoolean)
If FirstTime Then
pop.Initialize("pop.mailserver.com", 110, "username", "password", "pop")
'pop.UseSSL = True ' uncomment if SSL required
pop.Status
listSubject.Initialize
listFrom.Initialize
EndIf
Activity.LoadLayout("Start")
pop.ListMessages
End Sub
Sub POP_StatusCompleted (Success AsBoolean, NumberOfMessages AsInt, TotalSize AsInt)
messageCount = NumberOfMessages
Log("Success=" & Success & ", NumberOfMessages=" & NumberOfMessages & ", TotalSize=" & TotalSize)
End Sub
Sub POP_ListCompleted (Success AsBoolean, Messages AsMap)
If Success = FalseThen
Log(LastException.Message)
Else
'download all messages
'change last parameter to True if you want to delete the messages from the server
Log("Messages.Size = " & Messages.Size)
For i = 0 To Messages.Size - 1
pop.DownloadMessage(Messages.GetKeyAt(i), False)
Next
EndIf
pop.Close
End Sub
Sub POP_DownloadCompleted (Success AsBoolean, MessageId AsInt, MessageText AsString)
If Success = FalseThen
Log("LastException = " & LastException.Message)
Else
'Parse the mail
Dim M AsMessage
M = MailParser.ParseMail(MessageText, File.DirRootExternal)
'Log("M = " & M)
Log("MessageID = " & MessageId)
'Log("Subject = " & M.Subject)
listSubject.Add(M.Subject)
listFrom.Add(M.FromField)
'Log("listFrom.Size = " & listFrom.Size)
'Log("MessageCount = " & messageCount)
If listFrom.Size = messageCountThen
CreateScrollView
EndIf
EndIf
End Sub
Would someone with a better understanding of how mail servers work comment on this. Is this normal behavior? Is there some means of compensating for this when retrieving messages? Any enlightenment will be greatly appreciated.
Best regards
Last edited: