/* ------------------------------------------------------------------------ :Program. Vacation.rexx :Contents. automatically reply mails :Author. Kai Bolay [kai] :Address. Snail Mail: EMail: :Address. Hoffmannstraße 168 UUCP: kai@amokle.stgt.sub.org :Address. D-71229 Leonberg FIDO: 2:2407/106.3 :History. v1.0 [kai] 15-Oct-93 :History. v1.1 [kai] 12-Nov-93 now works with local msgs :History. v1.2 [hG] 16-Jan-94 improofed argument parsing :History. v1.3 [hG] 23-Jan-94 uses UMSInit.rexx 1.1 and :History. hgRexxSupport.library :History. v1.4 [olk] 19-Jul-94 updated for hgrexxsupport 1.2 :History. added addlib checking :History. moved UMSInit.rexx to REXX: :Version. $VER: Vacation.rexx 1.4 (19.7.94) :Copyright. Public Domain :Language. ARexx :Translator. RexxMast ------------------------------------------------------------------------ */ /*** Startup ***/ ProgramName = "Vacation"; ArgsTemplate = "Name,Password,Server/K" libname = "hgrexxsupport.library" if ~show("L", libname) then do if ~addlib(libname, 0, -30) then do say libname "not added!" exit end end interpret include("REXX:UMSInit.rexx") /* arguments are parsed here */ if rc ~= 0 then do say "cannot read UMS include-file!" exit 20 end /*** Login ***/ account = UMSLogin(name, password, server) if account = 0 then do say "unable to login." exit 10 end /*** Do the magic ***/ /* clear local flags 0, 1 and 2 on all messages */ res = UMSSelectFlags(account, "LOCAL", MakeFlags(), MakeFlags(0, 1, 2),,, "LOCAL", MakeFlags(), MakeFlags()) /* set local flag 1 on all private messages */ res = UMSSelectField(account, "LOCAL", MakeFlags(1), MakeFlags(),,, UMSCODE_Group, "", TRUE) /* set local flag 2 on all new, accessable and not postponed messages */ res = UMSSelectFlags(account, "LOCAL", MakeFlags(2), MakeFlags(),,, "USER", MakeFlags(UMSUSTAT_Old, UMSUSTAT_Postponed, UMSUSTAT_ReadAccess), MakeFlags(UMSUSTAT_ReadAccess)) /* set local flag 0 on all messages with flag 1 AND flag 2 set */ res = UMSSelectFlags(account, "LOCAL", MakeFlags(0), MakeFlags(),,, "LOCAL", MakeFlags(1, 2), MakeFlags(1, 2)) last = 0 do forever /* find next message with flag 0 set */ last = UMSSearchFlags(account, "LOCAL", MakeFlags(0), MakeFlags(0), last) if last = 0 then leave drop msg. /* _IMPORTANT_ */ if ~ReadUMSMsgAll(account, last, msg.,true) then do call CheckErr exit end drop newmsg. if symbol("msg." || UMSCODE_ReplyName) ~= "VAR" then do newmsg.UMSCODE_ToName = msg.UMSCODE_FromName if symbol("msg." || UMSCODE_FromAddr) = "VAR" then do newmsg.UMSCODE_ToAddr = msg.UMSCODE_FromAddr end end; else do newmsg.UMSCODE_ToName = msg.UMSCODE_ReplyName if symbol("msg." || UMSCODE_ReplyAddr) = "VAR" then do newmsg.UMSCODE_ToAddr = msg.UMSCODE_ReplyAddr end end newmsg.UMSCODE_RefID = msg.UMSCODE_MsgID newmsg.UMSCODE_Subject = "I'm on vacation!" newmsg.UMSCODE_MsgText = "Please be patient!" || '0A0A'x || "Bye!" newmsg.UMSCODE_ReplyName = "Please do not Reply!" newmsg.UMSCODE_ReplyAddr = "muell@deponie.erde" /* set attripute "reciept" */ num = WriteUMSMsg(account, newmsg.) if num = 0 then do call CheckErr end; else do say "The new message got #" || num end /* mark message as postponed but unread (works only if ums.library > 10.15 */ call UMSSelectMsg(account,"USER", MakeFlags(UMSUSTAT_Postponed), MakeFlags(UMSUSTAT_Old), last) end /*** Final cleanup ***/ BREAK_C: BREAK_D: BREAK_E: BREAK_F: ERROR: HALT: IOERR: SYNTAX: IF RC ~= 0 THEN DO SAY "Error: " rc errortext(rc) "Line" sigl END /*** Logout ***/ if account ~= 0 then do call UMSLogout(account) account = 0 end exit /*** Support ***/ CheckErr: procedure expose account err = UMSErrNum(account) if err ~= 0 then do say "UMS Error #" || err || ": " || UMSErrTxt(account) end return