'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, "my@gmail.com", "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