Jump to content

Move email from one folder to another in outlook


Go to solution Solved by water,

Recommended Posts

Ok I have no idea how to get this to do what I want.  I am now able to parse data from the email but next step is to then move the email over to a new folder.

I am using #include <OutlookEX.au3> to open outlook and once complete I just want to move the email so I don't keep processing the same file over and over again.  $inbox and $inbox success are variables assigned earlier that just point to a folder in my mail inbox.

$auOutlook = _OL_Open() ; Open outlook
$auOutlookCount = _OL_ItemFind($auOutlook,$inbox,$olMail,"","","","","",4) ;
$auOutlookItems = _OL_ItemFind($auOutlook,$inbox,$olMail,"","","","EntryID")
$Success = _OL_FolderAccess($auOutlook, $inboxsuccess)
$oItem = _OL_ItemMove($auOutlook, $auOutlookItems, $inbox, $success)
 
Here is the info from the file where it gives me the required parameters.
 Name ..........: _OL_ItemMove
; Syntax.........: _OL_ItemMove($oOL, $vItem, $sStoreID, $vTargetFolder[, $iFolderType = Default])
; Parameters ....:
$oOL           - Outlook object returned by a preceding call to _OL_Open()
$vItem         - EntryID or object of the item to move
$sStoreID      - StoreID of the source store as returned by _OL_FolderAccess. Use "Default" to access the users mailbox
$vTargetFolder - Target folder object as returned by _OL_FolderAccess or full name of folder
$iFolderType   - Optional: Type of target folder if you specify the folder name of another user. Is defined by the Outlook OlDefaultFolders enumeration (default = Default)
 
 
Link to comment
Share on other sites

I thought I was closer as it appears that _OL_FolderAccess returns an array with the following values

 Return values .: Success - one-dimensional one based array with the following information:
 
1 - Object to the folder
2 - Default item type (integer) for the specified folder. Defined by the Outlook OlItemType enumeration
3 - StoreID (string) of the store to access the folder by ID
4 - EntryID (string) of the folder to access the folder by ID
5 - Folderpath (string)
 
I tried this....but still no luck....I think storeid is correct but the vItem is still not right.....the second parameter is the issue ... I think
 
$auOutlook = _OL_Open() ; Open outlook 
$auOutlookCount = _OL_ItemFind($auOutlook,$inbox,$olMail,"","","","","",4) ; 
$auOutlookItems = _OL_ItemFind($auOutlook,$inbox,$olMail,"","","","EntryID") 
$Success = _OL_FolderAccess($auOutlook, $inboxsuccess) 
$oItem = _OL_ItemMove($auOutlook, $success[4], $success[3], $inboxsuccess)
Edited by Kurto2021
Link to comment
Share on other sites

Try:

$oOutlook = _OL_Open() ; Open outlook 
$aOutlookItems = _OL_ItemFind($auOutlook, $inbox, $olMail,"","","","EntryID") 
$iOutlookCount = $aOutlookItems[0][0]
$aSuccess = _OL_FolderAccess($auOutlook, $inboxsuccess) 
$oItem = _OL_ItemMove($oOutlook, $aOutlookItems[$i][0], Default, $aSuccess[1])

You don't need to run _OL_ItemFind twice to get the item count and the items.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

That's easy:

Use _OL_ItemGet to retrieve the subject and _OL_ItemModify to set the subject.

Use the item object returned bei _OL_ItemMove to access the moved item.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

says the man who wrote the UDF :)

That's easy:

 

so I figured I would change the subject then move it

I was thinking I was on the right track but not sure what to do with the returned values from itemget and what to fill in to do about $sp1

  $itemget = _OL_ItemGet($auOutlook, $auOutlookItems[1][0], Default, Default) 
 _OL_ItemModify($auOutlook, $auOutlookItems[1][0], Default, $sP1 = "")
 
Edited by Kurto2021
Link to comment
Share on other sites

But I hope it is easy for you too ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

  • Solution

I modified my last example:

$oOutlook = _OL_Open() ; Open outlook 
$aOutlookItems = _OL_ItemFind($auOutlook, $inbox, $olMail,"","","","EntryID") 
$iOutlookCount = $aOutlookItems[0][0]
$aSuccess = _OL_FolderAccess($auOutlook, $inboxsuccess) 
$aProperties = _OL_ItemGet($oOL, $aOutlookItems[$i][0], Default, "Subject")
$sSubject = "[Moved] " & $aProperties[1][1]
_OL_ItemModify($oOL, $aOutlookItems[$i][0], Default, "Subject=" & $sSubject)
$oItem = _OL_ItemMove($oOutlook, $aOutlookItems[$i][0], Default, $aSuccess[1])

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

I was close only needed to add subject to the itemget then add word subject= to the modify .....

$itemget = _OL_ItemGet($auOutlook, $auOutlookItems[1][0], Default, "subject")  
$auitemget = "ADD SOMETHING HERE " & $itemget
_OL_ItemModify($auOutlook, $auOutlookItems[1][0], Default, "Subject=" & $auitemget)

 

Water thanks for your help

Link to comment
Share on other sites

Glad to be of service :D

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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...