MohanRatnam

Move email to another folder in Outlook

9 posts in this topic

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



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 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 think _OL_ItemMove should look like:

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




			
		

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

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

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

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


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

Hello water,

was wonderin if there was any progress on this?

Share this post


Link to post
Share on other sites

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 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, 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