Jump to content

OutlookEX UDF - Help & Support (II)


water
 Share

Recommended Posts

Which hills?

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

hi water, you wisdom is again needed:

_OL_ItemFind() is used to retrieve a list of items in a folder, then some of the items are called by _OL_ItemSave().

although the script is checking the return codes of the above functions, if during the loop Outlook is closed, the following annoying message is displayed:

post-47848-0-24781300-1374440868_thumb.p

to handle this, the first thing comes to mind is something like this (before calling any Outlook method or _OL_ function):

If ProcessExists('OUTLOOK.EXE') Then ; go for it

you can suggest a more elegant method, i'm sure.

any thoughts are welcome. thanks,

orbs

edit: after several tests, it seems consistent that the error is in _OL_FolderAccess() in the following line:

$oFolder = $oNamespace.Folders($aFolders[1])
 
this expression crash the function when Outlook was closed. the next line does not execute at all:
 
If @error Or Not IsObj($oFolder) Then Return SetError(4, 1, "")
Edited by orbs

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

I removed the sync part because I wanted to have a simple reproducer. If copying the folders to a PST works then we can add the sync part again.

My above example doesn't sync but does it do the copy job correct?

 

Hi Water,

I have been trying to get the create pst function to work but are stuck with an OL-Open @error= 5 and @extended=0 which i can not get resolved. I am running on a Win 7 x64 machine with Office 2010 x32 installed on it.

#include <OutlookEX.au3>
#include <Array.au3>
#include <File.au3>
_OL_Open() 
SplashTextOn("Please wait", "Mailbox sync in progress." & @CRLF & @CRLF & "If a window asking for your ID and password pops-up," & @CRLF & "please enter them and click on OK." & @CRLF & @CRLF & "Once you entered your ID and password or if they were not asked," & @CRLF & "please do not use your computer while this window is showing." & @CRLF & @CRLF & "Sync time is approximatively around 1 min.", 600, 215, -1, -1, 18)
$outlook = _OL_Open(True)
If @error Then Exit MsgBox(0, "Error", "_OL_Open: @error = " & @error & ", @extended = " & @extended)

$pst = _OL_PSTCreate($outlook, @UserProfileDir & "C:\outlook\exchangebackup.pst", "Exchange backup")
If @error Then Exit MsgBox(0, "Error", "_OL_PSTCreate: @error = " & @error & ", @extended = " & @extended)

SplashTextOn("Please wait", "Mailbox backup in progress." & @CRLF & @CRLF & "If a window asking for your ID and password pops-up," & @CRLF & "please enter them and click on OK." & @CRLF & @CRLF & "Once you entered your ID and password or if they were not asked," & @CRLF & "please do not use your computer while this window is showing." & @CRLF & @CRLF & "Backup time depends on how large your mailbox is.", 600, 215, -1, -1, 18)

$folders = _OL_FolderTree($outlook, "*")
If @error Then Exit MsgBox(0, "Error", "_OL_FolderTree: @error = " & @error & ", @extended = " & @extended)
For $i = 2 To UBound($folders) - 1 Step 1
If StringInStr(StringMid($folders[$i], 3), StringMid($folders[0], 3)) <> 0 Then
$current_folder = _OL_FolderAccess($outlook, StringMid($folders[$i], 3))
If @error Then Exit MsgBox(0, "Error", "_OL_FolderAccess for folder: " & $folders[$i] & ". @error = " & @error & ", @extended = " & @extended)
_OL_FolderCopy($outlook, $current_folder[1], $pst)
If @error Then Exit MsgBox(0, "Error", "_OL_FolderCopy for folder: " & $folders[$i] & ". @error = " & @error & ", @extended = " & @extended)
EndIf
Next
_OL_Close($outlook)
SplashOff()

I am fairly new in scripting but would appreciate your help.

Thanks

Patrick

Link to comment
Share on other sites

Orbs,

you could grab the Quit event. This event is fired when Outlook is being closed.

Example:

#AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_Au3Check_Stop_OnWarning=Y
#include <OutlookEX.au3>

; *****************************************************************************
; Example Script
; Handle Outlook Quit event when Outlook is being closed.
; This script loops until Shift-Alt-E is pressed to exit.
; *****************************************************************************
HotKeySet("+!e", "_Exit") ;Shift-Alt-E to Exit the script
MsgBox(64, "OutlookEX UDF Example Script", "Hotkey to exit the script: 'Shift-Alt-E'!")

Global $oApp = _OL_Open()
Global $test = ObjEvent($oApp, "oOApp_")

While 1
    Sleep(10)
WEnd

; Outlook 2007 - Quit event - http://msdn.microsoft.com/en-us/library/bb208174%28v=office.12%29.aspx
Func oOApp_Quit()

    MsgBox(64, "OutlookEX UDF Example Script", "Outlook is being closed!" & @CRLF & "Goodby ")
    Exit

EndFunc

Func _Exit()
    Exit
EndFunc   ;==>_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

Pat11,

could you please remove the second call to _OL_Open?

Does this change anything?

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

 

Orbs,

you could grab the Quit event. This event is fired when Outlook is being closed.

Example:

#AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_Au3Check_Stop_OnWarning=Y
#include <OutlookEX.au3>

; *****************************************************************************
; Example Script
; Handle Outlook Quit event when Outlook is being closed.
; This script loops until Shift-Alt-E is pressed to exit.
; *****************************************************************************
HotKeySet("+!e", "_Exit") ;Shift-Alt-E to Exit the script
MsgBox(64, "OutlookEX UDF Example Script", "Hotkey to exit the script: 'Shift-Alt-E'!")

Global $oApp = _OL_Open()
Global $test = ObjEvent($oApp, "oOApp_")

While 1
    Sleep(10)
WEnd

; Outlook 2007 - Quit event - http://msdn.microsoft.com/en-us/library/bb208174%28v=office.12%29.aspx
Func oOApp_Quit()

    MsgBox(64, "OutlookEX UDF Example Script", "Outlook is being closed!" & @CRLF & "Goodby ")
    Exit

EndFunc

Func _Exit()
    Exit
EndFunc   ;==>_Exit

 

thanks water, this seems to work, i'm now testing it.

two notes:

1) the _Quit event exists for Outlook 2003 too.

2) i wonder if it works when Outlook crashes? i'm now testing it, but timing is important here, so it might take me a while.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

Thanks for the feedback!

I don't think if Outlook crashes it will be able to send the Quit event. Test it by killing the Outlook process.

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

Pat11,

could you please remove the second call to _OL_Open?

Does this change anything?

Hi Water,

removed the _OL_Open in line 6. The msgbox just quickly flashes on the screen. It now gives me an error as following:

C:UsersPatrick.BueckenDocumentstest.au3 (8) : ==> Variable used without being declared.:

$pst = _OL_PSTCreate($outlook, @UserProfileDir & "exchangebackupexchangebackup.pst", "Exchange backup")
$pst = _OL_PSTCreate(^ ERROR
>Exit code: 1    Time: 3.249
 
Thank you
Link to comment
Share on other sites

Sorry, my bad.

The object returned by _OL_Open is needed by the other functions. So please remove the first occurrence of _OL_Open:

_OL_Open()  ; <====== Remove this one
SplashTextOn("Please wait", "Mailbox sync in progress." & @CRLF & @CRLF & "If a window asking for your ID and password pops-up," & @CRLF & "please enter them and click on OK." & @CRLF & @CRLF & "Once you entered your ID and password or if they were not asked," & @CRLF & "please do not use your computer while this window is showing." & @CRLF & @CRLF & "Sync time is approximatively around 1 min.", 600, 215, -1, -1, 18)
$outlook = _OL_Open(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

 

Sorry, my bad.

The object returned by _OL_Open is needed by the other functions. So please remove the first occurrence of _OL_Open:

_OL_Open()  ; <====== Remove this one
SplashTextOn("Please wait", "Mailbox sync in progress." & @CRLF & @CRLF & "If a window asking for your ID and password pops-up," & @CRLF & "please enter them and click on OK." & @CRLF & @CRLF & "Once you entered your ID and password or if they were not asked," & @CRLF & "please do not use your computer while this window is showing." & @CRLF & @CRLF & "Sync time is approximatively around 1 min.", 600, 215, -1, -1, 18)
$outlook = _OL_Open(True)

Thansk Water just tried no more _OL_Open error but now is says:

C:Program Files (x86)AutoIt3IncludeOutlookEX.au3 (4398) : ==> Error in expression.:
Local $oNamespace = $oOL.GetNamespace("MAPI")
Local $oNamespace = ^ ERROR
Link to comment
Share on other sites

What is the value of @error and @extended after _OL_Open?

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

Do you really want to use the "WarningClick" feature that clicks away Outlook security warnings?

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

Do you really want to use the "WarningClick" feature that clicks away Outlook security warnings?

I am not quite sure what you mean. All i want to do is create a pst file with all the emails that are stored in folder and sub folder inside outlook for backup purpose. As i mentioned i am still learning, so any help is very much appreciated.

Link to comment
Share on other sites

In this case please change

$outlook = _OL_Open(True)

to

$outlook = _OL_Open()

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

Please insert

_OL_ErrorNotify(2)

before _OL_PSTCreate to get better error information.

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

Which version of Outlook do you run?

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

Another question: Does the directory/subdirectory you specified already exist?

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

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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