Page 2 of 4
Posted: Wed Jun 09, 2004 10:40 pm
by Andre
As I have no time to do a update to PureArea.net before the weekend, here is the direct download in the meantime:
www.purearea.net/pb/download/userlibs/bpePOP3_v0.1.zip
(spaces in file names for web use shouldn't be used I think)
Posted: Fri Jul 09, 2004 6:39 pm
by Shannara
I looked through the help, but couldnt find out if it works with multiple attachments, Anybody know?
Posted: Sun Jul 18, 2004 10:17 pm
by Shannara
Is BrendanE still part of the PB community?
Posted: Mon Jul 19, 2004 2:12 am
by GeoTrail
I know I'm doing something wrong here, but I'm not sure what.
Code: Select all
Size = POP3_GetMsgSize(GetGadgetState(#Mail_list)+1)
*buffer = AllocateMemory(Size)
; POP3_BufferMsgHeader(GetGadgetState(#Mail_list)+1, *buffer )
*myCallBack = POP3_SetDebugCallBack( @myCallBack() )
POP3_BufferMsgBody( GetGadgetState(#Mail_list)+1, *buffer, *myCallBack )
SetGadgetText(#Editor_0, PeekS(*buffer))
Haven't gotten the hang of memory handling, yet. Could someone please help me with this? I'm trying to get the email message and place it in the #Editor_0 gadget.
Posted: Wed Jul 21, 2004 8:23 pm
by BrendanE
Hi, I'm sorry for the very late response... had a hard drive crash - but yes I'm still here!
Posted: Wed Jul 21, 2004 8:28 pm
by thefool
hi!
Posted: Wed Jul 21, 2004 8:40 pm
by BrendanE
@GeoTrail :
Size = POP3_GetMsgSize(GetGadgetState(#Mail_list)+1)
*buffer = AllocateMemory(Size)
; POP3_BufferMsgHeader(GetGadgetState(#Mail_list)+1, *buffer )
*myCallBack = POP3_SetDebugCallBack( @myCallBack() )
POP3_BufferMsgBody( GetGadgetState(#Mail_list)+1, *buffer, *myCallBack )
SetGadgetText(#Editor_0, PeekS(*buffer))
You have 2 problems with your code GeoTrail :
1) - the callback. POP3_SetDebugCallBack() is used purely for debugging purposes (since the library is potentially still under development). This is the wrong callback to specify for POP3_BufferMsgBody().... I'll show you the correct method below.
2) The function POP3_BufferMsgBody() runs asychronously (presuming no initail error is reported by the function and it begins downloading the message)... this means that it returns execution to your program immediately.... the callback function is used by the library to call your application whenever data is received - to signal the download percentage, or an error, or that the message has completed. Your code tries to use the buffer immediately - when in fact the message will not be completed yet.. you need to use the signal from the callback to know that the message is done downloading.
Here is a skeleton example of what you need to do :-
Code: Select all
Global *buffer, inTransaction
*buffer = AllocateMemory( <sufficient memory> )
inTransaction = 0
Procedure messageCallBack(msg, param1, param2)
Select msg
Case #POP3MSG_DOWNLOADCOMPLETE
; Now you can send the message text to your window/text buffer/whatever here...
inTransaction = 0
Case #POP3MSG_ERROR
; check the last error and presume that the connection is lost
inTransaction = 0
Case #POP3MSG_DOWNLOADPROGRESS
; you could do something with the percentage (param1) like update a progress bar or whatever...
EndProcedure
POP3_Init/Connect/Logon to your email account....
..... now to buffer the message body as you wish to...
If inTransaction = 0
If POP3_BufferMsgBody( <msgnumber>, *buffer, @messageCallBack() )
inTransaction = 1
EndIf
EndIf
Hope this clear some things up - good luck.... if you still have problems let me know.
BrendanE
Posted: Wed Jul 21, 2004 8:41 pm
by BrendanE
Hi theFool!

Posted: Wed Jul 21, 2004 8:45 pm
by BrendanE
@Shanarra : Sorry - I missed seeing your question!!
Well it downloads the complete message text / attachments and all in whatever encoded format they are in... you would have to parse those yourself.
Try downloading a message and saving it as .eml - then use Outlook to open it - you'll see what I mean.
Cheers, BrendanE
Posted: Wed Jul 21, 2004 9:09 pm
by GeoTrail
Thanks BrendanE.
That helped alot.
Still learning
What would you reccommend I set the buffer alocation level to? Is 1000 too much or too small?
Posted: Wed Jul 21, 2004 9:19 pm
by BrendanE
in a real world app you must ensure you have allocated enough to contain the entire message (you did this correctly in your previous code using the GetMsgSize() function)... (remembering to either free up the memory - or reallocate the same block every time).
but if you want to work on a test scenario and you know that your message sizes will be small - yes, 1000 will be fine.
Posted: Wed Jul 21, 2004 9:35 pm
by GeoTrail
OK, thanks alot for your advice

Posted: Mon Aug 02, 2004 9:42 pm
by Mowen
Hi,
Thanks for this great library. Very usefull.
I just noticed one problem: sometimes (depends on the POP3 server and the message header format) the function POP3_HeaderFrom() returns a blank string for the field From. I think it is because it exists more than one space character between the "From:" and the following text in the message header. Thus a small parser problem.
Posted: Tue Aug 03, 2004 9:09 am
by BrendanE
I'm glad you find it useful.

Thankyou for finding that. I will fix it.
Posted: Tue Aug 03, 2004 12:38 pm
by Mowen
Ok I will parse the From field myself meanwhile you fix it in the library.
I use this library for checking new e-mails and for deleting spam messages before downloading to my mailboxes. It works fine. Thanks to PureBasic and bpePOP3.
You could add a function to return the Message_ID (unique identifier for each message) coming from the header. Sometimes it is usefull to know it.