Jump to content
MohanRatnam

Move email to another folder in Outlook

Recommended Posts

MohanRatnam

Hello,

I'm trying to do some work using the Outlook UDF. I can't figure out how to move email which I have just sent from the sent folder to another folder which I have created.

As you can guess, I'm no expert so please bear with me.

Here's my code

Global $oOutlook = _OL_Open()
$oItem = _OL_Wrapper_SendMail($oOutlook, "blahblah@outlook.com", "", "", "New Requisition", "")
_OL_ItemMove($oOutlook, $oItem, "*\Sent Items", "*\Requisitions\1. Submitted")

when i run it falls over with this error message

"C:\Program Files\AutoIt3\Include\OutlookEX.au3" (3125) : ==> Variable must be of type "Object".:
If $oSourceFolder.DefaultItemType <> $vTargetFolder.DefaultItemType Then Return SetError(2, 0, 0)
If $oSourceFolder^ ERROR
 
Thanks  :wacko:

Share this post


Link to post
Share on other sites
water

Which version of AutoIt do you run?

Which version of the OutlookEX UDF do you use?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.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
water

I think _OL_ItemMove should look like:

_OL_ItemMove($oOutlook, $oItem, Default, "*\Requisitions\1. Submitted")




			
		

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.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
MohanRatnam

According to the front page of the Autoit helpfile I have ver v3.3.12.0.

Outlook Ex UDF is ver 1.0.0.0 

Share this post


Link to post
Share on other sites
MohanRatnam

I have tried with the code 

_OL_ItemMove($oOutlook, $oItem, Default, "*\Requisitions\1. Submitted")

and still get the same error message

Share this post


Link to post
Share on other sites
water

I will test as soon as I return to my office.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.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
MohanRatnam

Hello water,

was wonderin if there was any progress on this?

Share this post


Link to post
Share on other sites
water

Ops, sorry, I forgot to post my findings-

The problem is caused by the fact that $oItem no longer exists - because it has been sent.

The item created in the "Sent Mails" folder has got a different EntryID.

So to move the item from the "Sent Mails" folder you either need to use _OL_ItemFind and search by subject, recipient, date etc. or use an event to wait for a new mail item to arrive in the "Sent Mails" folder.

An example can be found in the Example Scripts section (a link can be found in my signature).


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.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
MohanRatnam

water, thank you very much for all your help.

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

×