Help needed with this simple job.

Discuss RoboTask here
Post Reply
chimera123
Posts: 1
Joined: Mon Jul 15, 2013 6:14 pm

Help needed with this simple job.

Post by chimera123 »

Hello,

I want to create below job, but don´t figure out how to attached the newest file to an email.

Sequence:

Monitor a specific folder, wait for a new file to arrive.
When file arrives, attach this file to an email and send to an specific email.

How can I manage that that the "latest" file with be used an an attachement?

thanks
bye
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Help needed with this simple job.

Post by Oleg »

You can use file loop with sorting.
Use the sorting by file time with descending ordering (see screenshot below):
Sorting.png
Sorting.png (34.56 KiB) Viewed 7432 times
The 1-st file in the loop is a newest file.

The full example:

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1663346572
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task321"
Hide=INTEGER|0
ID=INTEGER|720565277
LogOnAsUser=INTEGER|1
Name=STRING|"Latest file in the folder"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""FILENAME"" with value """""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"FILENAME"

[Actions\Action2]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER

[Actions\Action2\Params]
createmode=STRING|"1"
date1=STRING|"20130716"
date2=STRING|"20130716"
destvar=STRING|"FILENAME"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"d:\temp\*.*"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"1"
sortby=STRING|"1"
sortorder=STRING|"1"
subdirs=STRING|"1"
timesize=STRING|"0"
WithoutPath=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Latest file is : {filename}"""
Params=FOLDER

[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"Latest file is : {filename}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action4]
ActionID=STRING|"A_LOOP_BREAK"
Enabled=INTEGER|-1
Name=STRING|"Break"

[Actions\Action5]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"


Also I recommend you to use such algorithm:
Suppose you have two folders: incoming and sent
You should monitor only "incoming" folder.
When the folder changed you send all files via email from incoming folder as attachment and move all files into "sent" folder.
Thus, "sent" folder contains only already sent files and incoming folder is empty by default and it can contain only new files.
Oleg Yershov
Post Reply