/* PGPwrite.rexx 1.1 by knikulai@utu.fi - 07-May-97
** Go check http://www.utu.fi/~knikulai/ARexx.html for other useful scripts!
**
** The ID/address you give must be such that PGP can find the right public key 
** 
** Environment variables PGPPASS and PGPPATH need to be set correctly
*/

options results
call addlib('rexxreqtools.library',0,-30,0)
call addlib('rexxsupport.library',0,-30,0)

scrn='YAMscreen'		/* Change the correct value here or leave it like this*/
editor='c:ed'			/* You probably have a better choice*/
subject='Top secret'		/* You could leave this empty */
outdir='ram:'			/* Message is saved here */
pgp='work:pgp/bin/pgp -sea'	/* Path and encoding options for PGP */

id=rtgetstring('',"Enter recipient's ID or address",'PGPencode by knikulai@utu.fi',' Ok | Quit','',s1)
if s1=0 | na='' then exit

call delete(outdir'coded.msg')
call delete(outdir'plain.msg')


address command 
editor outdir'plain.msg'

Call Close(STDOUT)
Call Close(STDIN)

Call Open(STDOUT,'CON:1/11/638/130/PGP Output/CLOSE/WAIT/SCREEN'scrn,'w')
Call Pragma('*',STDOUT)
Call Open(STDIN,'*')
pgp outdir'plain.msg -o' outdir'coded.msg' id

address 'YAM' 
'Show'
'MailWrite'
'WriteSubject "'subject'"'
'WriteMailTo "'id'"'
'WriteLetter "'outdir'coded.msg"'
Call Close(STDOUT)
Call Close(STDIN)
exit
