Sign in to follow this  
Followers 0
lolipop

Need help to create script for outlook task

85 posts in this topic

Hi,

I'm looking for help to do the following task but not really sure if AutoIt script can do the trick. Perhaps someone can advise me and help me in create this script?

Basically this is the task. Assume I have 2 outlook profile within the same computer. I wish to automate the task to

1 - Open outlook profile 1

2 - Search for the folder called "Shared Folder"

3 - There is a single file within the Shared Folder. Extract this file out and copy to a temp location.

4 - Close outlook and re-launch outlook using outlook profile 2.

5 - Move or copy the earlier extracted file to this outlook profile 2. There is a folder called Shared Folder 2. Just place it in there.

6 - Close outlook.

The script will need to run probably every 2 hours so I'm thinking of using scheduler to run the script. Can this be done using AutoIt. Please help.Thanks.

Share this post


Link to post
Share on other sites



Yes it can. Chech the Outlook extended UDF created by Water.

Share this post


Link to post
Share on other sites

Yes it can. Chech the Outlook extended UDF created by Water.

Thanks for the reply but I'm very sorry I'm don't quite understand how the Outlook UDF works. Like I mention before, I'm a total newbie to this autoit thingy. Sorry.

Share this post


Link to post
Share on other sites

Quick and dirty:

#include <OutlookEx.au3>
$sTitle = "Outlook Test Script"
$oOutlook = _OL_Open(False, "", 0, 0, "Profile1")
If @error Then Exit MsgBox(16, $sTitle, "Error returned by _OL_Open: " & @error & ", @extended: " & @extended)
$aFolder = _OL_FolderAccess($oOutlook, "Your Shared Folder")
If @error Then Exit MsgBox(16, $sTitle, "Error returned by _OL_FolderAccess: " & @error & ", @extended: " & @extended)
$aItems = _OL_ItemFind($oOutlook, $aFolder[1], "... Parameters To describe the search follow here ...")
If @error Then Exit MsgBox(16, $sTitle, "Error returned by _OL_ItemFind: " & @error & ", @extended: " & @extended)
_OL_Close($oOutlook)
Exit

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

Quick and dirty:

#include <OutlookEx.au3>
$sTitle = "Outlook Test Script"
$oOutlook = _OL_Open(False, "", 0, 0, "Profile1")
If @error Then Exit MsgBox(16, $sTitle, "Error returned by _OL_Open: " & @error & ", @extended: " & @extended)
$aFolder = _OL_FolderAccess($oOutlook, "Your Shared Folder")
If @error Then Exit MsgBox(16, $sTitle, "Error returned by _OL_FolderAccess: " & @error & ", @extended: " & @extended)
$aItems = _OL_ItemFind($oOutlook, $aFolder[1], "... Parameters To describe the search follow here ...")
If @error Then Exit MsgBox(16, $sTitle, "Error returned by _OL_ItemFind: " & @error & ", @extended: " & @extended)
_OL_Close($oOutlook)
Exit

Hi water,

Thanks for the advise. I try out your script but somehow it doesn't open the Profile1 automatically. Outlook just start and prompt me which profile to use. Thanks.

Share this post


Link to post
Share on other sites

What version of Outlook 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

It's outlook 2007..

Share this post


Link to post
Share on other sites

If the profile needs a password then use:

#include <OutlookEx.au3>
$sTitle = "Outlook Test Script"
$oOutlook = _OL_Open(False, "", 0, 0, "Profile1", "Your password goes here")
If @error Then Exit MsgBox(16, $sTitle, "Error returned by _OL_Open: " & @error & ", @extended: " & @extended)
$aFolder = _OL_FolderAccess($oOutlook, "Your Shared Folder")
If @error Then Exit MsgBox(16, $sTitle, "Error returned by _OL_FolderAccess: " & @error & ", @extended: " & @extended)
$aItems = _OL_ItemFind($oOutlook, $aFolder[1], "... Parameters To describe the search follow here ...")
If @error Then Exit MsgBox(16, $sTitle, "Error returned by _OL_ItemFind: " & @error & ", @extended: " & @extended)
_OL_Close($oOutlook)
Exit


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

really appreciate your help.

The outlook profile doesn't need password. My outlook profile 1 is named "Outlook", profile 2 is "test"

I try changing the code to reflect my profile name

$oOutlook = _OL_Open(False, "", 0, 0, "Outlook") or

$oOutlook = _OL_Open(False, "", 0, 0, "test")

doesn't work. any further idea?

Share this post


Link to post
Share on other sites

Do you get an error MsgBox?


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

no error msg return from _ol_open.

Outlook just prompt me to choose the profile to load

Posted Image

Share this post


Link to post
Share on other sites

I will check and - hopefully - post a solution.


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

If you start Outlook manually do you have a default profile Outlook connects to or do you still get the prompt?


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

#15 ·  Posted (edited)

If I start outlook manually, I will also get the prompt becos in control panel -> Mail, I have set Outlook to prompt for a profile to be used(pic below). With this setting, when I run the script, I will always get the outlook prompt as shown in the pic above.

Posted Image

I have also try setting the Mail option to always use this profile(Outlook), the script works as in no outlook prompt but when I try changing the script code to load another outlook profile such as the test profile, outlook seems to be still loading the Outlook profile(default) rather than the profile I specific in the script.

Edited by lolipop

Share this post


Link to post
Share on other sites

Make sure that Outlook isn't started when you run the script - else Outlook ignores the parameters passed by the script.

Set "Prompt for a profile to be used" and re-try, maybe it works :oops:


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

tired but doesn't work :oops:

Share this post


Link to post
Share on other sites

Looks like line

$oOL_Namespace.Logon($sOL_ProfileName, $sOL_Password, False, False)
in function _OL_Open needs to be set to
$oOL_Namespace.Logon($sOL_ProfileName, $sOL_Password, True, True)


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

Tried changing the $oOL_Namespace.Logon but still having the same result. Wheneven the script run, outlook still prompt me to choose the profile to load.

Btw, can I know what's the True, True do? Cos I can't find any help/info for this.

Share this post


Link to post
Share on other sites

Sure. Here you can find the Logon method and the required parameters.

Could you again change the line to

$oOL_Namespace.Logon($sOL_ProfileName, $sOL_Password, False, True)

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