Jump to content

Recommended Posts

Posted

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.

  • Replies 84
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted

  On 3/28/2012 at 7:04 AM, 'Juvigy said:

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.

Posted

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:

  Reveal hidden contents

 

Posted

  On 3/28/2012 at 7:34 AM, 'water said:

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.

Posted

What version of Outlook do you use?

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

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:

  Reveal hidden contents

 

Posted

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?

Posted

Do you get an error MsgBox?

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

I will check and - hopefully - post a solution.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

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:

  Reveal hidden contents

 

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
Posted

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:

  Reveal hidden contents

 

Posted

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:

  Reveal hidden contents

 

Posted

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.

Posted

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:

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...