Get unread Email

Discuss RoboTask here
Post Reply
kravtsov
Posts: 6
Joined: Thu Nov 10, 2016 7:09 am

Get unread Email

Post by kravtsov »

Hi!

How can I download unread messages from using POP3 or IMAP and mark them as "read"?

It is easy to download all messages using LOOP. But I don't understand how can I get the number of unread messages.
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Get unread Email

Post by Oleg »

IMAP Mail loop action allows to save the message flags too

To save flags (attributes) of the current message, switch on this checkbox and specify the variable name. Flags of the message will be saved as string. Every letter corresponds to existence of a flag of the message.
  • A - Answered
    F - Flagged
    D - Deleted
    S - Seen
    T - Draft
    R - Recent
For example,
AS - means that the message is answered and seen.
R – recent message.

There is IMAP Get Message Flags to save message flags within the loop into varable

Also look at my example below.
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1040932817
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task149"
Hide=INTEGER|0
ID=INTEGER|-122231251
LogOnAsUser=INTEGER|1
Name=STRING|"download unread messages (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
Action8=FOLDER
Action9=FOLDER

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

[Actions\Action1\Params]
folder=STRING|"INBOX"
host=STRING|"imap.myserver.com"
password=STRING|"4438845245462874500344480"
passwordmode=STRING|"0"
port=STRING|"993"
SSL=STRING|"1"
user=STRING|"username"

[Actions\Action2]
ActionID=STRING|"A_IMAP_LOOP"
Enabled=INTEGER|-1
Name=STRING|"IMAP Mail loop"
Params=FOLDER

[Actions\Action2\Params]
flags=STRING|"Flags"
number=STRING|"num"
usecc=STRING|"0"
usedate=STRING|"0"
useflags=STRING|"1"
usefrom=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"
Params=FOLDER

[Actions\Action3\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"9"
type=STRING|"0"
value1=STRING|"S"
value2=STRING|"{Flags}"

[Actions\Action4]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//process unread messages here"
Params=FOLDER

[Actions\Action4\Params]
comment=STRING|"process unread messages here"

[Actions\Action5]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//you can dowload it too"
Params=FOLDER

[Actions\Action5\Params]
comment=STRING|"you can dowload it too"

[Actions\Action6]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//and set ""read"" flag"
Params=FOLDER

[Actions\Action6\Params]
comment=STRING|"and set ""read"" flag"

[Actions\Action7]
ActionID=STRING|"A_IMAP_SETFLAGS"
Enabled=INTEGER|-1
Name=STRING|"IMAP Set Message Flags"
Params=FOLDER

[Actions\Action7\Params]
answered=STRING|"2"
deleted=STRING|"2"
draft=STRING|"2"
flagged=STRING|"2"
msgnum=STRING|"{num}"
recent=STRING|"2"
seen=STRING|"1"

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

[Actions\Action9]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
Oleg Yershov
kravtsov
Posts: 6
Joined: Thu Nov 10, 2016 7:09 am

Re: Get unread Email

Post by kravtsov »

Thanks!
Post Reply