Jump to content

Need help to create script for outlook task


Recommended Posts

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.

Link to comment
Share on other sites

  • Replies 84
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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.

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

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.

Link to comment
Share on other sites

What version of Outlook do you use?

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

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

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?

Link to comment
Share on other sites

Do you get an error MsgBox?

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 will check and - hopefully - post a solution.

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

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

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

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

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.

Link to comment
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 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...