E-mail from Win32Forth (A Simple How To)

 

Frank Russo - June 2007

This is meant to be a very simple set of routines to access your e-mail server. What you do with the access is up to you.

Thanks goes to Jos van de Ven and his 4ePost program.

I needed this in order to give my AI-Mind program access to receive and reply to email.

At this moment (10 Jun 07) the routines ONLY process incoming mail. It does not handle Attachments and does not send mail. (That's for Later)


User Words:

Init-connection ( - Flag )

Init-inmail ( Add1 n Add2 n Add3 n - Flag )

Init-outmail ( Add1 n - Flag )

Get-Mail-List ( - Addr N )

Delete-Msg ( - Flag )

Delete-Mail ( - Flag )

Get-Mail-Stats ( - Count Size )

Get-msg-headers ( - Addr N )

Retrieve-Msg ( n - Addr N Flag )

Close-email ( - )

encrypt/decrypt$ ( adr count - adr count )

 

User Variables:

 
110 value pop3-port  \ default value
 
110 value smtp  \ default value
 
0 value #recs  \ # of messages in the inbox
 
0 value msg-size  \ Size of the largest message on server
 


 
\ WORKING EXAMPLE
WinLibrary WININET.DLL
Needs Sock.f
Needs email-interface.f
\
\ **************************************************************************************
\
\ *********************************************************************************
\
: Test-email
\
Init-connection \ Initialize connections, returns a flag if successful, MUST be called first
If \ Successful Internet connection made
   S" account password" S" username for account" S" mail.server.com" init-inmail
\
 If \ Successful log onto host
\
\ Your processing code
\
  Get-mail-stats ( - N N ) \ Returns the # of messages and the total size on the stack
  S" Number of messages on server = " type swap . 5 spaces
  S" Size = " type . cr
\
  Get-Mail-List  ( -  Adr N )  cr type cr cr
\
  Get-msg-headers \ ( -  Addr N )  \ Get a listing of messages 
  1+ 0 do i over i + c@ emit loop cr cr
\
\ end of check for any mail available
\ 
  Close-email
 
 else s" Unable to Login on to Host" cr type cr
 
 then \ End of check for login
 
else s" Unable to Connect" cr type cr
 
then \ End of check for internet connection
;
\
\ *********************************************************************************
\
Example Connection:
 
Number of messages on server = 11      Size = 35713
 
1 1335
2 8112
3 2215
4 9638
5 2262
6 1601
7 3181
8 669
9 2700
10 2352
11 1648
 
 1 - Subject: =?utf-8?B?QUk=?=                From: =?utf-8?B?RnJhbmsgUnVzc28=?=
 2 - Subject: Biscutti                        From: Frank Russo whome@yahoo.com
 3 - Subject: Site test                       From: Frank Russo whome@yahoo.com
 4 - Subject: Fwd: We're Moving Again!        From: Frank Russo whome@yahoo.com
 5 - Subject: AI                              From: Frank Russo whome@yahoo.com
 6 - Subject: AI                              From: "Frank Russo" materialsengineering@lycos.com
 7 - Subject: AI                              From: "John Russo" johnthefart@nologic.com
 8 - Subject: AI                              From: Tim Russo tmanrusso@peoplesuck.com
 9 - Subject: E-mail Test as requested        From: RicktheMartian wgasa@yahoo.com
10 - Subject: AI                              From: whocaresAldrich@bellsfart.com
11 - Subject: AI                              From: Francis.Russo@jetstream.com
 
--------------------------------------------------------------------------------