Jump to content
Gowrisankar

Required help to move mails to different folder

Recommended Posts

Gowrisankar

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.

Share this post


Link to post
Share on other sites
Gowrisankar

I found it myself. Used "EntryID" along with "Subject".

Pointed the "EntryID" column of the array to move the mail. It worked.

 

Thanks and regards,

Gowrisankar R.

Share this post


Link to post
Share on other sites
water

:)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
dhardyuk

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

Share this post


Link to post
Share on other sites
Gowrisankar
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.

Share this post


Link to post
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

  • Similar Content

    • nooneclose
      By nooneclose
      Good afternoon, I am in need of some help. I am sure this is a stupid question requiring only one or two lines of code. However, I would greatly appreciate the help I cannot figure this out. I also tried searching for the answer on the internet but no one except me apparently seems to be having a hard time figuring this out and or is asking about it. 
      I simply want to change the "status" of an email from unread to read once I have processed it. My code is over 500 lines and I would like not to clutter this post with it. Assume I have all my includes and connections properly defined and stuff. 
      Here is the bit of code where I am trying to change the email that was used from unread to read:
      Func ChangeEmailStatus() ;******************************************************************************* ; changes the status of an email from unread to Read ;******************************************************************************* Local $iRows = UBound($aItems, $UBOUND_ROWS) MsgBox("", "Number of Unread emails (Before Change)", $iRows) _OL_ItemModify($oOutlook,$aItems[$i][0], Default, "Read=True") MsgBox("", "Array Display 1", $aItems[1][0]) MsgBox("", "Array Display 2", $aItems[2][0]) Local $iRows = UBound($aItems, $UBOUND_ROWS) MsgBox("", "Number of Unread emails (After Change)", $iRows) EndFunc  
    • nooneclose
      By nooneclose
      Hello again everyone, I am trying to make a simple bot/AI to help me at work. I need it to read the subject line of emails, open them if a certain subject line is found, and then copy the contents of the said email and paste it in a different program. 
      Can the Autoit outlook UDF help me achieve this? 
      Also, I have tried the Outlook UDF and so far I have only figured out how to find all the unread emails (thanks to one of water's example scripts. @water you are a genius just saying).
      I am very new to this UDF and would love any help that would guide me into making this bot/AI a reality at work.   
    • caramen
      By caramen
      I watched _OL_ItemSend&_OL_ItemFind&_OL_ItemCreate in OutlookEx UDF but hmmm
       
      Since it use the test environnement i cant get the orders of the mail creation
       
      Can someone make me win some time of reading all exemples script and lead me how to do one ?
      That whould be lovely.
      Gnight
    • water
      By water
      Extensive library to control and manipulate Microsoft Outlook.
      Theads: Development - General Help & Support - Example Scripts - Wiki
      BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort

      KNOWN BUGS (last changed: 2018-09-01)
      None
×