sequence eMail_adres
sequence briefje
sequence subject
sequence file_path ={}
sequence file_attach
sequence OPVOOR,OMPOULE
include readf.e
include makemail.e
subject=command_line()
if length(subject)<3
then puts(1,"Using mkabr begeleidendschrijven_file eMails_file\n") abort(1)
else briefje=subject[length(subject)-1]
eMail_adres=subject[length(subject)]
end if
integer brief_file=open(briefje,"r"),i
sequence brief={},line,org_naam,mails
if brief_file>2
then line=gets(brief_file)
while sequence(line) do
brief&=line
line=gets(brief_file)
end while
close(brief_file)
else puts(1,"Error begeleidend schrijven is zoek\n")
abort(1)
end if
brief_file=open(eMail_adres,"r")
if brief_file<3
then puts(1,"Error eMails zijn zoek\n") abort(1)
end if
line =readf(brief_file,',')
subject=line[1]
OPVOOR =line[2]
OMPOULE=line[3]
i=find('$',brief)
i=find('$',brief[i+1..])+i
brief=brief[1..i-1]&OPVOOR&brief[i+1..]
i=find('$',brief[i+1..])+i
brief=brief[1..i-1]&OMPOULE&brief[i+1..]
if Logon() then puts(1,"Error on log on\n") abort(0) end if
line =readf(brief_file,',')
while sequence(line) and length(line) do
if length(line)=4 then
file_attach={file_path&line[1],file_path&line[2]}
org_naam=line[3]
mails =line[4]
puts(1,"send to: "&mails&'\n')
i=find('$',brief)
line=brief[1..i-1]&org_naam&brief[i+1..]
if length(file_attach)
then i=sendfile(mails,subject,line,file_attach)
else puts(1,"Error , no file's\n")
end if
if i
then printf(1,"Error = %d at eMail = %s\n",{i,mails}) abort(1)
else puts(1,"eMail is send\n")
end if
else
puts(1,"Error in mail file\n")
end if
line=readf(brief_file,',')
end while
close(brief_file)
if Logoff() then puts(1,"Error on log off\n") abort(0) end if