Jump to content

Required help to move mails to different folder


Recommended Posts

Dear members,

I'm trying to move unread mails from Inbox to a different folder using OutlookEx UDF.

But its not working for me. I'm not sure what mistake I do.

I get the error code 6 when the following is executed. From the UDF it is observed that  "No or an invalid item has been specified".

Note : The UDF version is 1.3.3.1. AutoIt version (v3.3.14.2).

#include <OutlookEX.au3>

Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)

Global $aOL_Item = _OL_ItemFind($oOutlook, "*\Inbox", $olMail, "[UnRead]=True", "", "", "Subject", "", 1)
If $aOL_Item[0][0] = 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemMove Example Script", "Could not find a task item in folder 'Outlook-UDF-Test\SourceFolder\Tasks'. @error = " & @error)
_ArrayDisplay($aOL_Item, "OutlookEX UDF: _OL_ItemFind Example Script - Unread mails")
_OL_ItemMove($oOutlook, $aOL_Item[1][0], Default, "*\Outlook-UDF-Test\TargetFolder\Mail")
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemMove Example Script", "Error moving specified task. @error = " & @error)

Any help is deeply appreciated. Thanks in advance.

Thanks and regards,

Gowrisankar R.

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

  • 3 weeks later...

Sorry,

I'm having a hiccup with moving items to new folders and I'm a bit slow on the uptake this morning.

I have a nice script that runs through the inbox and creates a CSV file of the email contents (the emails are html forms that come from an external partner and need to be loaded into our CMDB). What I want it to do next is move the processed email into a time stamped folder so I can debug any issues.

I'm having a brain fart trying to think it through so please excuse anything below that is painfully obvious!

Was the error you had with this line?

_OL_ItemMove($oOutlook, $aOL_Item[1][0], Default, "*\Outlook-UDF-Test\TargetFolder\Mail")

and was it resolved by changing it to this

_OL_ItemMove($oOutlook, $aOL_Item[0][0], Default, "*\Outlook-UDF-Test\TargetFolder\Mail")

Or am I off track?

Thanks

David

Link to comment
Share on other sites

3 hours ago, dhardyuk said:

Sorry,

I'm having a hiccup with moving items to new folders and I'm a bit slow on the uptake this morning.

I have a nice script that runs through the inbox and creates a CSV file of the email contents (the emails are html forms that come from an external partner and need to be loaded into our CMDB). What I want it to do next is move the processed email into a time stamped folder so I can debug any issues.

I'm having a brain fart trying to think it through so please excuse anything below that is painfully obvious!

Was the error you had with this line?

_OL_ItemMove($oOutlook, $aOL_Item[1][0], Default, "*\Outlook-UDF-Test\TargetFolder\Mail")

and was it resolved by changing it to this

_OL_ItemMove($oOutlook, $aOL_Item[0][0], Default, "*\Outlook-UDF-Test\TargetFolder\Mail")

Or am I off track?

Thanks

David

Thanks for your response @dhardyuk. The error was in "_OL_ItemFind" statement where I used only "Subject". Since there was no unique identifier it threw an error. After changing it to "EntryId,Subject" (combination of Entry Id and Subject of the body) the error was resolved.

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

×
×
  • Create New...