Sign in to follow this  
Followers 0
Kurto2021

Move email from one folder to another in outlook

11 posts in this topic

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)
 
 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

water you rule!!!!   Of course now I am being asked to add the word completed to the beginning of the subject when I move it.  Ugh.....you get one thing to work and they ask for more.  

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

But I hope it is easy for you too ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I can't get it to work...Just not sure what I am doing wrong

Share this post


Link to post
Share on other sites

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


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

Share this post


Link to post
Share on other sites

Glad to be of service :D


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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
Sign in to follow this  
Followers 0