home *** CD-ROM | disk | FTP | other *** search
- /*****************/
- /* Multisend.ems */
- /**************************************************************************/
- /* */
- /* Multisend config file format: */
- /* */
- /* NAME = the string that identifies a multisend session. */
- /* */
- /* FROM = the 'From' field of the messages. */
- /* SUBJECT = the 'Subject' field of the messages. */
- /* ORIGIN = optional origin line. */
- /* TO = the destination of a message, <name> ^ <address> ^ [<area>] */
- /* where: <name> is the 'To' field of the message. */
- /* <address> is the 'To' address. */
- /* <area> is the area of the message. */
- /* */
- /* (leaving empty the area causes a netmail multisend). */
- /* */
- /* Ex: To="All^^Test" -> echo message in area 'Test' */
- /* To="Davide Massarenti^2:332/505@fidonet.org^" -> mail message. */
- /* */
- /* */
- /**************************************************************************/
- /* $VER: Multisend.ems 1.0 (29.08.93) */
- /***************************************/
-
- options results
- signal on error
- signal on syntax
-
- parse arg which files
-
- if( ~show( 'l', "ems_rexx.library" ) ) then
- do
- if( ~addlib( "ems_rexx.library", 0, -30, 0 ) )then
- do
- say "Could not open ems_rexx.library"
- exit 10
- end
- end
-
- /*trace r*/
-
- files = strip( files, 'B' )
-
- if files = '' then
- do
-
- say "Usage: MultiSend.ems <setting's part> <file to send> [<file to send> ...]"
- signal ExitScript
-
- end
-
- file.0 = 0
-
- do while length( files ) ~= 0
-
- parse var files name files
-
- if exists( name ) = 0 then
- do
-
- say "Can't find file <" || name || ">"
- signal ExitScript
-
- end
-
- call EMS_Add_To_Stem( 'file', name, 'UNIQUE' )
-
- end
-
-
- cfg_version = '1.0'
- cfg_name = 'MultiSend'
- cfg_mail = FindMailArea()
- cfg_def_orig = EMS_Var_Local( 'ORIGIN_NAME' )
-
-
- call EMS_CustomCfg_Search( cfg_name, which, 'items' )
-
- do i=1 to items.0
-
- item_from.0 = 0
- item_subj.0 = 0
- item_to.0 = 0
- item_orig.0 = 0
-
- if EMS_CustomCfg_Get( cfg_name, items.i, 'From' , 'item_from' ) != 'OK' | item_from.0 = 0 then iterate
- if EMS_CustomCfg_Get( cfg_name, items.i, 'Subject', 'item_subj' ) != 'OK' | item_subj.0 = 0 then iterate
- if EMS_CustomCfg_Get( cfg_name, items.i, 'To' , 'item_to' ) != 'OK' | item_to.0 = 0 then iterate
- if EMS_CustomCfg_Get( cfg_name, items.i, 'Origin' , 'item_orig' ) != 'OK' then iterate
-
- if item_from.0 ~= 0 then msg_from = item_from.1
- if item_subj.0 ~= 0 then msg_subj = item_subj.1
- if item_orig.0 ~= 0 then msg_orig = item_orig.1
- else msg_orig = cfg_def_orig
-
- do j=1 to item_to.0
-
- parse var item_to.j msg_to '^' msg_to_addr '^' msg_area
-
- if msg_area = '' then msg_area = cfg_mail
-
- /*
- ** Get infos about the message area.
- */
- area_type = EMS_Area_Type( msg_area )
- area_addr = EMS_Area_Address( msg_area )
-
- call EMS_Item_Alloc( 'write_msg', msg_area, 'msg' )
- call EMS_Item_Header_From( 'write_msg', msg_from )
- call EMS_Item_Header_To( 'write_msg', msg_to )
- call EMS_Item_Header_Subject( 'write_msg', msg_subj )
- call EMS_Item_Header_Address_From( 'write_msg', area_addr )
- call EMS_Item_Header_Address_To( 'write_msg', area_addr )
-
- if upper( area_type ) = 'MAIL' then
- do
-
- call EMS_Item_Header_Flag( 'write_msg', 'PVT', 'TRUE' )
- call EMS_Item_Header_Address_To( 'write_msg', msg_to_addr )
-
- end
- else
- do
-
- call EMS_Item_Line_Unique( 'write_msg', 'header', '--- ' , '--- MultiSend v' || cfg_version )
- call EMS_Item_Line_Unique( 'write_msg', 'header', ' * Origin: ', ' * Origin: ' || msg_orig || ' (' || area_addr || ')' )
-
- end
-
- do k=1 to file.0
-
- call EMS_Item_File_Read( 'write_msg', 'text', file.k, 'APPEND' )
-
- end
-
- call EMS_Item_Write( 'write_msg' )
- call EMS_Item_Free( 'write_msg' )
-
- end
-
- end
-
- ExitScript:
-
- call EMS_FreeScriptData()
- exit 0
-
-
- error:
- syntax:
-
- error_text = EMS_LastError()
-
- if error_text = '' then error_text = rc ErrorText( rc )
-
- say '| ***BREAK: error at' sigl error_text
-
- call EMS_FreeScriptData()
- exit rc
-
-
- FindMailArea: procedure
-
- call EMS_Areas( 'a' )
-
- do i=1 to a.0
-
- if upper( EMS_Area_Type( a.i ) ) = 'MAIL' then return a.i
-
- end
-
- return ''
-