Jump to content

Move unread emails from a specific sender to a folder


Recommended Posts

Hi Water :)

Thank you very much for sharing your UDFs. I know that there is many similar issues to the one I have already on the forum, but I tried different codes and nothing worked for me :( since I'm new to autoit and to programing in general I have hard time figuring this out:

I'm trying to use your OutlookEX UDF to move unread emails from a specific sender to a folder.

For now I was trying to see if I can manage to move unread emails from all users to the folder "Unread mails" but it doesn't work

can you please tell me what is the issue with my code?
 

#RequireAdmin

#include <File.au3>
#include <Array.au3>
#include <OutlookEX.au3>


Global $oOutlook = _OL_Open()
$vFolder = _OL_FolderAccess($oOutlook, "*")
$item_find =_OL_ItemFind($oOutlook, $vFolder, $olMail,"[UnRead]=True", "", "", "", "", 1)
if $item_find[0][0] = 0 Then MsgBox(0, "", @error & "/" & @extended)

_ArrayDisplay($item_find, "unread emails")
_OL_ItemMove($oOutlook, $item_find[1][0], Default, "*unread Mails")

 

Link to comment
Share on other sites

_OL_FolderAccess returns an array. Element 1 holds the folder object.

; #RequireAdmin 

#include <File.au3>
#include <Array.au3>
#include <OutlookEX.au3>

Global $oOutlook = _OL_Open()
If @error Then MsgBox(0, "", "_OL_Open: " & @error & "/" & @extended)
$aFolder = _OL_FolderAccess($oOutlook, "*")
If @error Then MsgBox(0, "", "_OL_FolderAcces: " & @error & "/" & @extended)
$item_find =_OL_ItemFind($oOutlook, $aFolder[1], $olMail,"[UnRead]=True", "", "", "EntryID", "", 1)
If @error Then MsgBox(0, "", "_OL_ItemFind: " & @error & "/" & @extended)

_ArrayDisplay($item_find, "unread emails")
_OL_ItemMove($oOutlook, $item_find[1][0], Default, "*\unread Mails")
Edited by water
_OL_ItemFind returns the EntryID so _OL_ItemMove works

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

thank you for your response, I corrected and it seems to create a new folder "unread mails", however, the function _OL_ItemMove doesn't move the unread emails to the new folder, it shows error# 6 and extended: -2147024809

_OL_ItemMove($oOutlook, $item_find[1][0], Default, "*unread Mails")

 

Link to comment
Share on other sites

Updated my script above.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thank you for your help, it works perfectly now. can you please tell me in which function can I add a parameter to get only unread emails from a particular sender moved to the folder instead of moving all unread emails?

 

thank you in advance, your help is much appreciated.

Nina

Link to comment
Share on other sites

You could add the properties SenderName or SenderEmailAddress to be returned by _OL_ItemFind (right now you just get the EntryID) and then check for the correct Name or Address before moving the item.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

:)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...