Files
harbour-core/contrib/hbtip/tests/tipmail.prg
vszakats 9687850865 2013-03-16 02:10 UTC+0100 Viktor Szakats (harbour syenar.net)
* (all files)
    * stripped svn header
    * minor cleanups
    ; use following command to find out the history of files:
       git log
       git log --follow
       git blame
       git annotate
2013-03-16 02:11:42 +01:00

59 lines
1.4 KiB
Plaintext

/******************************************
* TIP test
* Mail - reading and writing multipart mails
*
* Test for reading a multipart message (that must already
* be in its canonical form, that is, line terminator is
* CRLF and it must have no headers other than SMTP/Mime).
*
* This test writes data to standard output, and is
* compiled only under GTCGI;
******************************************/
#require "hbtip"
PROCEDURE Main( cFileName )
LOCAL oMail, cData, i
IF cFileName != NIL
cData := MemoRead( cFileName )
IF FError() > 0
? "Can't open", cFileName
QUIT
ENDIF
ENDIF
oMail := TIPMail():New()
IF oMail:FromString( cData ) == 0
? "Malformed mail. Dumping up to where parsed"
ENDIF
? "-------------============== HEADERS =================--------------"
FOR i := 1 TO Len( oMail:hHeaders )
? hb_HKeyAt( oMail:hHeaders, i ), ":", hb_HValueAt( oMail:hHeaders, i )
NEXT
?
? "-------------============== RECEIVED =================--------------"
FOR EACH cData IN oMail:aReceived
? cData
NEXT
?
? "-------------============== BODY =================--------------"
? oMail:GetBody()
?
DO WHILE oMail:GetAttachment() != NIL
? "-------------============== ATTACHMENT =================--------------"
? oMail:NextAttachment():GetBody()
?
ENDDO
? "DONE"
?
/* Writing stream */
/* FWrite( 1, oMail:ToString() ) */
RETURN