Sub Process_Globals
Dim pop As POP3
Dim SetTextSize As Boolean
Dim M As Message
Dim aIndex As Int
Dim messageCount As Int
Dim arraySubject() As String
Dim arrayFrom() As String
Dim Subject As String
Dim From As String
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
pop.Initialize("pop.mailserver.net", 110, "username", "password", "pop")
'pop.UseSSL = True ' uncomment if SSL required
pop.Status
End If
Activity.LoadLayout("Start")
pop.ListMessages
End Sub
Sub POP_StatusCompleted (Success As Boolean, NumberOfMessages As Int, TotalSize As Int)
messageCount = NumberOfMessages
Log("Success=" & Success & ", NumberOfMessages=" & NumberOfMessages & ", TotalSize=" & TotalSize)
End Sub
Sub POP_ListCompleted (Success As Boolean, Messages As Map)
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.Size = " & Messages.Size)
For i = 0 To Messages.Size - 1
pop.DownloadMessage(Messages.GetKeyAt(i), False)
Next
End If
pop.Close
End Sub
Sub POP_DownloadCompleted (Success As Boolean, MessageId As Int, MessageText As String)
If Success = False Then
Log("LastException = " & LastException.Message)
Else
Log("MessageID = " & MessageId)
'Parse the mail
M = MailParser.ParseMail(MessageText, File.DirRootExternal)
Log("M = " & M)
' ############# put Subject and From headers into two arrays here #####################
Dim arraySubject(messageCount) As String '( ReDim Arrays for messageCount here
Dim arrayFrom(messageCount) As String '(
aIndex = 0
For i = 0 To messageCount - 1
arraySubject(aIndex) = M.Subject '( how do I get the headers into
arrayFrom(aIndex) = M.FromField '( a correctly indexed array???
aIndex = aIndex + 1
Next
' #####################################################################################
CreateScrollView
End If
End Sub
Sub Activity_Pause(UserClosed As Boolean)
End Sub
Sub Activity_Resume
End Sub
Sub CreateScrollView
Dim ScrollView1 As ScrollView
Dim lstChecks As List
Dim Height As Int
Dim FontSize As Int
Dim FontColor1 As Int : FontColor1 = Colors.White
Dim FontColor2 As Int : FontColor2 = Colors.Black
Dim Panel1 As Panel
Dim yAxis As Int
SetTextSize = True ' this inserted just for testing - normally set in settings
If SetTextSize = True Then
Height = 60dip
FontSize = 16
Else
Height = 45dip
FontSize = 12
End If
ScrollView1.Initialize(500)
Panel1 = ScrollView1.Panel
'If Label5.Visible = False Then ' adjusts ScrollView height depending on number buttons
yAxis = 100%y - 105dip
'Else If Label5.Visible = True Then
'yAxis = 100%y - 150dip
'End If
Activity.AddView(ScrollView1, 0, 50dip, 100%x, yAxis)
lstChecks.Initialize
aIndex = 0
For i = 1 To messageCount
Dim chk As CheckBox
chk.Initialize("chkBoxSelection")
Subject = arraySubject(aIndex) 'get the item from the array
chk.Text = Subject
chk.textSize = FontSize
If i Mod 2 = 0 Then
chk.TextColor = FontColor1
chk.Color = Colors.DarkGray
Else
chk.TextColor = FontColor2
chk.Color = Colors.White
End If
chk.tag = i
lstChecks.Add(chk)
Dim lbl1 As Label
lbl1.Initialize("")
From = arrayFrom(aIndex) 'get the item from the array
lbl1.Text = From
lbl1.textSize = FontSize
lbl1.Gravity = Gravity.CENTER_VERTICAL
If i Mod 2 = 0 Then
lbl1.TextColor = FontColor1
lbl1.Color = Colors.DarkGray
Else
lbl1.TextColor = FontColor2
lbl1.Color = Colors.White
End If
Panel1.AddView(chk, 0, Height * (i - 1), 50%x, Height)
Panel1.AddView(lbl1, 50%x, Height * (i - 1), 50%x, Height)
aIndex = aIndex + 1
Next
Panel1.Height = lstChecks.Size * Height
End Sub