<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>MS Outlook Module - Get only unread email  &amp;amp; Set email as Read</title><link>https://community.appian.com/discussions/f/rpa/19319/ms-outlook-module---get-only-unread-email-set-email-as-read</link><description>Hi, I&amp;#39;m using MS Outlook Module to get a email list and then working on them, I have already implemented these steps. Now I would get email list but only unread email, then I need to mark the emails in this list as read. What is the best way to do it</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: MS Outlook Module - Get only unread email  &amp; Set email as Read</title><link>https://community.appian.com/thread/75618?ContentTypeID=1</link><pubDate>Tue, 28 Jul 2020 06:52:17 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:d5e16eea-5272-4494-bcd2-21c155358357</guid><dc:creator>David Catalan</dc:creator><description>&lt;p&gt;It is not possible get an email list with only unread emails. The behavior of the MSOutlook module is the same as you can get using the GUI. When you access to a folder, you see by default all the emails.&lt;/p&gt;
&lt;p&gt;The&amp;nbsp;IOlMailItem object contains a property to know whether the email has been read. You can use mailItem.getUnread() method.&lt;/p&gt;
&lt;p&gt;To mark an email as read, you can do the same thing as in the GUI, show the email, and close it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here you are an example:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;			IOlFolderFW criteria = new OlFolderFW();
			criteria.setFolderPath(&amp;quot;\\\\myAccount@myCompany.com\\Inbox&amp;quot;);
			List&amp;lt;IOlFolder&amp;gt; folderList = outlook.getOlFolderManager().findFolder(criteria);
			         
			List&amp;lt;IOlMailItem&amp;gt; mailList = outlook.getOlFolderManager().getMailList(folderList.get(0).getEntryID());
			         
			for (IOlMailItem mailItem : mailList) {
				if (mailItem.getUnRead()) {
					server.info(&amp;quot;Mail Unread, Subject &amp;lt;&amp;quot;+mailItem.getSubject()+&amp;quot;&amp;gt;, Sender &amp;lt;&amp;quot;+mailItem.getSenderName()+&amp;quot;&amp;gt;&amp;quot;);
					outlook.getOlMailManager().showMail(mailItem);
					//Do Something....
					outlook.getOlMailManager().closeMail(mailItem.getEntryID(), EInspectorClose.DISCARD);
				}
			}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;To manage this type of automation I recommend you don&amp;#39;t use the unread property to decide whether an email must be processed or not. I think it is better process all emails&amp;nbsp;in the input folder. When an email is processed, the robot can move the email to another folder ( called &amp;quot;processed&amp;quot; for example), to not be processed twice..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>