pop3securesocket (not receiving new messages!)

mailsocket.countmessages (which is run if (mailsocket.isConnected = true) Is not picking up new
messages :frowning:

Here is my forum post
Ok so… I have a program where I’m just trying to skim the paypal transaction ID’s from incoming payment notifications … I’m able to do this as well as parse the information successfully and store it in a text file. So in total I have 3 questions :slight_smile: The first one is crucial… the last 2 questions are what I’m going to refer as, as bonus questions.

The point of this program I’m making is to run continously to catch incoming emails … so I have a timer running that is set to multiple mode… and runs every 30,000 ms… or 30 seconds… In the timer… the first thing it checks for is the condition (mailsocket.isconnected) If that is true… (using mailsocket as a pop3securesocket…) then the idea is to simply countmessages which should fire off the rest of the event handlers in the mail socket… I would think ?

I took this from the incoming mail demo program… which @PaulLefvebre kindly adjusted for me to enable secure connection…

Anyways… my predicament is this… simply running mailsocket.countmessages will not pick up any new messages :frowning:
I try sending new messages while its connected and it runs, but no new messages appear.

Now: If I close the program and reopen it… voila… new message(s) will appear! So then I thought I know! I’ll disconnect from server and disconnect the socket and then reconnect… Nope this throws an error upon reconnection… Sigh…

Question 2: Is there an easy way to use ssh from within xojo to upload a file to a server (overwriting another file?)
Question 3: I forgot 3, this is good for now



I am going to take a ‘wild’ guess here and say you’re making a mistake somewhere.

The reason I’m saying that is because I have a project in development which uses the pop3 secure socket and I just tested it in RS 2010 r5 and Xojo r3 and they both get new email messages. I tested this by sending myself a new email message while my app was running and it appeared.

I haven’t looked at the code in over a year so I couldn’t tell you where you’re going wrong but because of your post I was concerned so I tested.

I’m actually sick in bed at the moment and am not ‘working’ so I won’t be looking at my code for a while, sorry.

You didn’t mention what version of xojo or RS you’re using but I’m not currently developing this project in xojo because of other bugs (previously experienced), slowness, and the inefficiently designed IDE.

Since I haven’t looked at my code in over year I could be wrong but I do think it’s working.
In the coming weeks as I go over the code if I find something that’s broken I’ll probably post it here.

At least now you know to recheck your code and that it should work.

Let me ask you this, what happens when you call



Real Studio 2012r2

[quote=43161:@Christopher Ridgeway]Let me ask you this, what happens when you call


You should get a MessageCount event. Are you getting that event, but with an incorrect count? Or are you not getting the event at all?

It appears to be going through the motions of counting… but it doesn’t ever fire the
toplinesretrieved and messagereceived event handlers… like it does when i first connect… or if i close and reopen the program…

Here’s the code from the event handlers of the mail socket.

StatusLabel.Text = “Connected…”

StatusLabel.Text = “Disconnected”

// Count the messages, which calls the MessageCount
// event handler
statusLabel.text = “Login success…”

g_count = count
msgCountLabel.text = "message count: " + str(g_count)
if g_count < 1 then
statusLabel.text = “No Messages…”
mMessageCounter = 1
end if

statusLabel.text = “Counting Messages…”
// Get each message, which will be processed
// by the TopLinesRetrieved event handler.
For i As Integer = 1 To count
Me.RetrieveLines(i, 0)

#Pragma Unused id

statusLabel.text = "message recieved " + str(g_count)

dim IDstart, IDend, IDlength as integer
Dim shell as new Shell
Dim textfile As Folderitem = SpecialFolder.CurrentWorkingDirectory.Child(“transids.txt”)
Dim transIDout as TextOutputStream
Dim transID As String
shell.timeout = 999999

IDstart = instr(email.BodyPlainText, “&id=”) + 4 //start of transaction ID in email
IDend = instr(IDstart, email.BodyPlainText, “>”)
IDlength = IDend - IDstart

if instr(email.BodyPlainText, “Transaction ID:”) > 0 and instr(email.Subject, “payment”) > 0 then

transID = trim(Mid(email.BodyPlainText, IDstart, IDlength))
shell.execute "type " + """" + textfile.AbsolutePath + """"
textarea1.text = shell.result

if instr(shell.result, transID) = 0 then
  transIDout = TextOutputStream.Append(textfile)
  if transID <> "" then
    transIDout.write(transID + ",0" + chr(13))
  end if
end if

end if

statusLabel.text = “Waiting…”

dim i, count as integer
statusLabel.text = “Top lines recieved…”
count = 1

//transfer needed variables to globals
g_subject = email.Subject
g_id = id

for i = 1 to g_count
count = count + 1

//reset all variables, as process is complete
mMessageCounter = 0
g_count = 0
g_id = 0
g_subject = “”

sorry if this is a mess :confused: I’m just beating my head against a wall right now with this.

You shouldn’t have any loops in your events. That’s sequential processing, not async event-driven coding. If it were me, I would

Call CountMessages

in the MessageCount event, save the count and call RetrieveMessage on the first one.

In MessageRecieved, process the message and call RetrieveMessage on the next index. Quit when you get to the saved count.

Tim you nailed it. THANKS!