Sub Process_Globals
Dim pop As POP3
Dim GlobalMessages As Map
Dim currentMessage As Int
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
pop.Initialize("pop.gmail.com", 995, "xxx", "xxx", "pop")
pop.UseSSL = True
End If
pop.ListMessages
End Sub
Sub POP_ListCompleted (Success As Boolean, Messages As Map)
If Success = False Then
Log(LastException.Message)
Else
Log(Messages.Size)
GlobalMessages = Messages
currentMessage = 0
DownloadMessage
End If
pop.Close
End Sub
Sub DownloadMessage
If currentMessage >= GlobalMessages.Size Then
Msgbox("All mails were downloaded", "")
Return
End If
pop.DownloadMessage(GlobalMessages.GetKeyAt(currentMessage), False)
currentMessage = currentMessage + 1
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
DownloadMessage
End Sub