Android Question pop.DownloadMessage does not clear emails

prokli

Active Member
Licensed User
Longtime User
Hello everybody,

I tried to run the POP3 example as shown within the forum and which has been discussed several times. So, I just want to delete emails whenever I called "pop.DownloadMessage(Messages.GetKeyAt(i), True)".
This does obviously NOT clear emails on the Google server ([email protected])!!

Furthermore, when I switch back to "False" (pop.DownloadMessage(Messages.GetKeyAt(i), False) " I can read the email exactly one time. Further calls do not return the same email(s).

Thanks for help
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
I tried to run the POP3 example as shown within the forum and which has been discussed several times. So, I just want to delete emails whenever I called "pop.DownloadMessage(Messages.GetKeyAt(i), True)".
This does obviously NOT clear emails on the Google server ([email protected])!!
According to the documentation (https://www.b4x.com/android/help/net.html#pop3_downloadmessage) the message will only be deleted after the connection is closed, so you need to make sure you close the connection before you check whether the email was deleted.

Furthermore, when I switch back to "False" (pop.DownloadMessage(Messages.GetKeyAt(i), False) " I can read the email exactly one time. Further calls do not return the same email(s).
This was explained by Erel here -> [Bug?] POP3.DownloadMessage vs. Messages.Size

- Colin.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
on certain unix-like systems, mail is marked as read/unread. once you download your mail, it's marked as read by the system. you can't download it again, but it's still there.

snippet from server:
Subject: delete or not delete

so, do you want to delete or not?
-----------------------------------------------------------------------

i read the message but didn't delete. snippet now from server:

Subject: delete or not delete
Status: RO

so, do you want to delete or not?
-----------------------------------------------------------------------
R = "has been Read"
O = "Old"
-----------------------------------------------------------------------
now if i try to read my mail:
$ mail
No mail for drgottjr
$

but the mail, she is still there.
 
Upvote 0

prokli

Active Member
Licensed User
Longtime User
I am closing the POP connection see this code:

B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim pop As POP3
End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
  
End Sub

Sub Activity_Create(FirstTime As Boolean)
   If firstTime Then
      POP.Initialize("pop.gmail.com", 995, "[email protected]", "mypwd", "pop")
      POP.UseSSL = True 
   End If
   pop.ListMessages
End Sub

Sub pop_ListCompleted (Success As Boolean, Messages As Map)
        Log ("Success: " & success)
   If Success = False Then
      Log(LastException.Message)
   Else
      'download all messages
      'change last parameter to True if you want to delete the messages from the server
      Log ("messages: " & Messages.Size)
      For i = 0 To Messages.Size - 1
         pop.DownloadMessage(Messages.GetKeyAt(i), False)
      Next     
   End If
   pop.Close   'Right here POP connection will be closed

End Sub

Sub pop_DownloadCompleted (Success As Boolean, MessageId As Int, MessageText As String)
   If Success = False Then
      Log(LastException.Message)
   Else
      Log(MessageId)
      'Parse the mail
      Dim m As Message
      m = MailParser.ParseMail(MessageText, File.DirRootExternal)
      Log(m)
   End If
End Sub

Sub Activity_Resume

Furthermore I get exactly one new message whenever it has arrived on Google Server (this seems to be okay to me!). When I call "pop.ListMessages" again (e.g. by a button press) no message is returned (although it has not been deleted!)
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
the software is behaving as it is supposed to. the 2 posts preceding yours explain why this is the case. once you download a message, it won't appear again regardless of whether you delete it or not. this may seem strange, but you need to understand pop and imap and what their purposes are. plus it's a little unclear why you would download your mail and immediately try to list it again. it's like taking your mail from mail carrier, and then asking him immediately if he has any mail for you.

plus mail retrieval is not being used today in the way it was originally envisioned by the founding fathers. the idea that you would download your mail on one computer and then download the same mail on a different device was unimagined. this is why web mail front ends have sprung into existence. as far as mail servers are concerned, once you pick up your mail, it won't give it to you again. whether you mark it for deletion or not is irrelevant.
 
Upvote 0

prokli

Active Member
Licensed User
Longtime User
I just prefer technical information, nothing else. So please do not publish your individual point of view and don't tell how to deal with emails today. As you might have seen, there is a "False" and "True" which can be provided to "pop.DownloadMessage(……,False)". If this Boolean value does not work at all, it would be enough to explain that. Thanks!
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
it works. it is working.
 
Upvote 0
Top