water Posted March 29, 2012 Posted March 29, 2012 Strange I haven't worked with Outlook profiles myself. But all I can find on the web uses the logon method the way I do it in my UDF.What operating system do you run (XP, Windows 7 ...)?What bit version of the OS do you run (32, 64)?Do you compile your script for 32 or 64 bit? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
lolipop Posted March 29, 2012 Author Posted March 29, 2012 I'm on 32Bit XP Pro SP3 with 32 bit scripting. Strange indeed... Do you know of any other ways to workaround this and get the job done?
water Posted March 29, 2012 Posted March 29, 2012 I can only think of one solution: Create an _OL_OpenEx version of _OL_Open that waits for the profile selection window to pop up, enter the selected profile name and then click the OK button. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
lolipop Posted March 29, 2012 Author Posted March 29, 2012 but with this option there will always be a prompt am I right? But I need to have everything run in the background without any GUI showing up. so sad
water Posted March 29, 2012 Posted March 29, 2012 but with this option there will always be a prompt am I right?Right.Do you have a Windows 7 computer around to test if the behavior we noticed is the same independant of the used OS? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
lolipop Posted March 30, 2012 Author Posted March 30, 2012 Hi water, Just used a Win7 Pro with Outlook 2010 machine to test it out. Same outcome. The Outlook still prompt me for the profile to load.
water Posted March 30, 2012 Posted March 30, 2012 Now I slowly run out of ideas I couldn't find anything on the web yet describing your problem. I'll keep on searching ... My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
lolipop Posted March 30, 2012 Author Posted March 30, 2012 Thanks water...Appreciate your help... if you need more information pls feel free to ask me......thanks once again
water Posted March 30, 2012 Posted March 30, 2012 (edited) As the MAPI logon doesn't seem to work you could start Outlook using function ShellExecute and pass the profile name as a command line switch:Global $iResult = ShellExecute("Outlook", "/profile xyz")then wait a few seconds. Use _OL_Open to connect to the running instance. Edited March 30, 2012 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
lolipop Posted April 2, 2012 Author Posted April 2, 2012 (edited) I notice using the shellexecute, I'm unable to hide or minimize the outlook windows even when I add in the @SW_Hide command. Also, if there is an existing outlook session, the script will launch another new session. If I run the script again, then there will be 3 windows of Outlook. Is there a way to hide the session and use the exisiting session without launching mulitple session? Also, I seem to encounter error trying to save the item find. I'm not sure if I have written the _OL_Itemsave parameters correctly #Include <OutlookEx.au3> $sTitle = "Outlook Test Script" Global $iResult = ShellExecute("Outlook", "/profile Outlook", "", "", @SW_HIDE) Sleep(5000) $oOutlook = _OL_Open(False, "", 0, 0, "Outlook") If @error Then Exit MsgBox(16, $sTitle, "Error returned by _OL_Open: " & @error & ", @extended: " & @extended) $aFolder = _OL_FolderAccess($oOutlook, "*Shared Folder") If @error Then Exit MsgBox(16, $sTitle, "Error returned by _OL_FolderAccess: " & @error & ", @extended: " & @extended) $aItems = _OL_ItemFind($oOutlook, $aFolder[1], "", "", "OutSwitch.au3", "", "", "", "", "") _OL_ItemSave($oOutlook, $aItems[1][0], Default, "D:test", $olHTML, 1) _OL_Close($oOutlook) ProcessClose("outlook.exe") Edited April 2, 2012 by lolipop
water Posted April 2, 2012 Posted April 2, 2012 The _OL_ItemFind syntax is wrong. What do you search for? The subject, the name of an attachment, the body? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
lolipop Posted April 2, 2012 Author Posted April 2, 2012 (edited) I'm searching for the subject name or attachment name. Either is fine. Save the attachment out to local harddisk and then open another outlook profile. Put that attachment into a permanent folder called "shared folder". Edited April 2, 2012 by lolipop
water Posted April 2, 2012 Posted April 2, 2012 (edited) Then please give this code a try:#include <OutlookEx.au3> $sTitle = "Outlook Test Script" Global $oOL ; Close all Outlook instances While 1 $oOL = ObjGet("", "Outlook.Application") If $oOL = 0 Then ExitLoop _OL_Close($oOL, True) WEnd ; Start Outlook with the specified profile ShellExecute("Outlook", "/profile Outlook", "", "", @SW_HIDE) If @error Then Exit MsgBox(16, $sTitle, "Error returned by ShellExecute: " & @error & ", @extended: " & @extended) Sleep(5000) $oOutlook = _OL_Open() If @error Then Exit MsgBox(16, $sTitle, "Error returned by _OL_Open: " & @error & ", @extended: " & @extended) $aFolder = _OL_FolderAccess($oOutlook, "*Shared Folder") If @error Then MsgBox(16, $sTitle, "Error returned by _OL_FolderAccess: " & @error & ", @extended: " & @extended) Else $aItems = _OL_ItemFind($oOutlook, $aFolder[1], $olMail, "", "Subject", "OutSwitch.au3", "EntryID") If @error Then MsgBox(16, $sTitle, "Error returned by _OL_ItemFind: " & @error & ", @extended: " & @extended) Else If $aItems[0][0] = 0 Then MsgBox(16, $sTitle, "Not mail items found!") Else _OL_ItemSave($oOutlook, $aItems[1][0], Default, "D:test", $olHTML, 1) If @error Then MsgBox(16, $sTitle, "Error returned by _OL_ItemSave: " & @error & ", @extended: " & @extended) EndIf EndIf Endif _OL_Close($oOutlook, True) If @error Then MsgBox(16, $sTitle, "Error returned by _OL_Close: " & @error & ", @extended: " & @extended) Edited April 2, 2012 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
water Posted April 2, 2012 Posted April 2, 2012 Another question: If you write the item/attachment to a public folder can't you just access this folder from the current profile and write the item to the public folder. You need to have the proper permissions but you can access every folder you like. So the cumbersome profile switching could be avoided. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
lolipop Posted April 2, 2012 Author Posted April 2, 2012 Is there a typo error in the sample code? I notice there's a "exit" at the middle of the code. I thought that will end the script halfway? correct me if i'm right. Thanks. Have try running with "exit" code, no error encounter by upon checking D:test folder. I don't see anything save there. Also, try running without the "exit" code, I got this error from the autoit message dialog. Any idea what it meant? Item in the wrong array? C:try.au3 (26) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: _OL_ItemSave($oOutlook, $aItems[1][0], Default, "D:test", $olHTML, 1) _OL_ItemSave($oOutlook, ^ ERROR >Exit code: 1 Time: 7.412
lolipop Posted April 2, 2012 Author Posted April 2, 2012 (edited) Btw, I'm have no idea about this public folder thingy. let me google it for more information first. Hmm...Don't think I see any public folders in my outlook. Maybe my organization IT staff disable them. Anyway. even if there is public folder, I don't think I can use them as I'm trying to access 2 separate exchange server profile and not within a single exchange server. Edited April 2, 2012 by lolipop
water Posted April 2, 2012 Posted April 2, 2012 Right, the "exit" is the remainder of a test i did - please remove. The error you get is caused by _OL_ItemFind not returning an item. I've modified my above example (and removed "exit") My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
water Posted April 2, 2012 Posted April 2, 2012 (edited) Btw, I'm have no idea about this public folder thingy. let me google it for more information first. Hmm...Don't think I see any public folders in my outlook. Maybe my organization IT staff disable them. Anyway. even if there is public folder, I don't think I can use them as I'm trying to access 2 separate exchange server profile and not within a single exchange server.You are talking about shared folders in your posts. Who shares the folders and who is the owner? Edited April 2, 2012 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
lolipop Posted April 2, 2012 Author Posted April 2, 2012 (edited) Returned error "No mail items found". Seems like _OL_itemfind still unable to find any item. weird. I'm sure there is an item in that folder. Edited April 2, 2012 by lolipop
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now