download email attachments

Discuss RoboTask here
Post Reply
carroll
Posts: 12
Joined: Wed Feb 11, 2009 2:58 pm

download email attachments

Post by carroll »

I receive 5 emails (GMAIL) per day. Each has 1 attachment with a unique name. I am only interested in the attachments and want to save each one to a folder on drive d as a csv file.
Not sure how to get started - don't understand IMAP POP ??
I have tried to use “Pop3 download email”, How do I find the “order number of the message”
I don’t care about saving the email message or saving the attachment as a variable.
Can you refer me to a link or a youtube video that describes how ROBOTASK can do this?
Thanks Carroll
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: download email attachments

Post by Oleg »

Not sure how to get started - don't understand IMAP POP ??
IMAP and POP3 - are email protocols. These protocols are standard and GMAIL supports them too.
How do I find the “order number of the message”
This is the ordering number of message on server. You can get it in the loop
The algorithm is similar to this

Code: Select all

Open POP3 server
POP3 Mail loop // loop on existing messages
   If MyCondition is true then
      Download message and extract attachments
      Delete this message from server
   end if 
end loop
The condition may be any. You can check the sender email or some key-phrase in email subject

Also look at my example below. It just an example
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
Also you can simply copy task text and paste it into the task list.
Next you can see it in the task editor

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1163085779
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1457"
Hide=INTEGER|0
ID=INTEGER|1389483016
LogOnAsUser=INTEGER|1
Name=STRING|"Get email attachment (Example)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

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

[Actions\Action1]
ActionID=STRING|"A_EMAIL_OPEN"
Enabled=INTEGER|-1
Name=STRING|"POP3 Open"
Params=FOLDER

[Actions\Action1\Params]
host=STRING|"Mail-server.com"
password=STRING|"4438845245462874500344480"
port=STRING|"995"
SSL=STRING|"1"
SSL2=STRING|"0"
SSL3=STRING|"0"
TLS10=STRING|"1"
TLS11=STRING|"1"
TLS12=STRING|"1"
user=STRING|"username"

[Actions\Action2]
ActionID=STRING|"A_EMAIL_LOOP"
Enabled=INTEGER|-1
Name=STRING|"POP3 Mail Loop"
Params=FOLDER

[Actions\Action2\Params]
breakafter=STRING|"0"
from=STRING|"sender"
limit=STRING|"100"
number=STRING|"num"
reverse=STRING|"0"
usecc=STRING|"0"
usedate=STRING|"0"
usefrom=STRING|"1"
usepriority=STRING|"0"
usesize=STRING|"0"
usesubj=STRING|"0"
useto=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then //check the condition"
Params=FOLDER

[Actions\Action3\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"0"
value1=STRING|"{sender}"
value2=STRING|"robot@myfirm.org"

[Actions\Action4]
ActionID=STRING|"E_EMAIL_DOWNLOAD"
Enabled=INTEGER|-1
Name=STRING|"POP3 Download Message"
Params=FOLDER

[Actions\Action4\Params]
attachfolder=STRING|"{TempDir}\attachments"
extract=STRING|"1"
num=STRING|"{num}"
overwrite=STRING|"0"
savefilenames=STRING|"0"
savetofile=STRING|"{TempDir}\{Year}{MonthNo}{Day}{Hours}{Minutes}{Seconds}{mSeconds}.eml"

[Actions\Action5]
ActionID=STRING|"A_EMAIL_DELETE"
Enabled=INTEGER|-1
Name=STRING|"POP3 Delete Email // delete downloaded email from server"
Params=FOLDER

[Actions\Action5\Params]
num=STRING|"{num}"

[Actions\Action6]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

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

Oleg Yershov
Post Reply