[comp.windows.news] mail-sender

frode@m2cs.uu.no (Frode Odegard) (06/19/89)

After installing newsbiff I was irritated by the fact that I had to use mail to
reply to messages, so I hacked a small utility called mail-sender. It is a
small NeWS program which opens up a window with two items; a text item where
the user can enter an email address and a "compose and send" button".

To send mail you enter an email address into the "To:" field (TextItem) and
click the "compose and send" button. The program will then use forkunix
to start "mail" in a psterm window (in which the mail is composed and
sent).

This is just a quick hack and no attempt to create a NeWS variant of mailtool.
It works well if you have newsbiff installed, except from the fact that
messages are not removed from the mail queue (newsbiff is just a biff program).

Sometimes the message written seems to just disappear into a black hole,
I suspect that this is due to some bug in the code for the TextItem class
(does it include control characters in the ItemValue, maybe?)

Anyway, here's the code:

%
% mail-sender.ps
%

systemdict /Item known not {
   (NeWS/liteitem.ps) run
} if

/notify {
   items /userName get /ItemValue get /toUser exch def
   (psterm -t sun -xy 300 300 -il "compose-mail" -co 80 -li 25 -fl "compose-mail" mail )
   toUser append
   forkunix
} def

/win framebuffer /new DefaultWindow send def
{
   /FrameLabel (mail-sender v0.1) def
   /PaintClient {items paintitems} def
   /IconImage /bulb def
} win send
300 700 280 100 /reshape win send
/map win send
/can win /ClientCanvas get def

/items 50 dict dup begin
   /button (compose and send) /notify can 15 15 /new ButtonItem send
      20 10 /move 3 index send def
   /userName (To: ) () /Right {} can 220 0 /new TextItem send dup
      /Itemframe 1 put 20 55 /move 3 index send def
end def

/myProcess items forkitems def

			- Frode
PS: This is ugly code - I know - pls. don't flame me ;-)

-- 
_____________________________________________________________________
Frode L. Odegard, Modula-2 CASE Systems, Maridalsveien 139, N-0461
OSLO 4, NORWAY. Email: frode@m2cs.uu.no. For a full resume send mail
to info@m2cs.uu.no (message must contain the command "resume frode").