/* zmime.zprx 1.0 (18.4.96) Copyright © Ralph Seichter */

zmime    = "Beta:zmime/zmime"
zmimecfg = "Beta:zmime/zmime.config"

/*-----------------------------------------------------------------------*/

options results
parse arg zpoint

zpoint = COMPRESS(zpoint)
if zpoint = "" then
    zpoint = "ZPoint"

address value zpoint

whichlevel
if result ~= "BOARD" then do
    requestnotify "You are not inside a board!"
    exit
end

temp = "T:zmime.zprx-"zpoint
address command "delete "temp" >NIL:"
savemessagebody temp
if ~rc then do
    requestnotify "Can't save message"
    exit
end

/* Load file into CED and create the necessary header information */

address 'rexx_ced'

status numchanges
numch = result
status numlines
numl = result
if (numl > 0 | numch > 0) then
    open new
open temp

beg of file
line = 0
do while line < 15
    status linebuffer
    if LEFT(result, 2) == '--' then do
        line = 99
        right
        right
        mark
        'end of line'
        copy
        beg of file
        lf = '0A'X
        text 'MIME-Version: 1.0'lf'Content-Type: multipart/mixed; boundary="'
        paste
        text '"'lf lf
        save
    end
    else do
        down
        line = line + 1
    end
end
quit

if line ~= 99 then do
    requestnotify "Can't find boundary"
    exit
end

/* Pass file to zmime */

address command zmime" "temp" PUBSCREEN "zpoint" CONFIG "zmimecfg
