Jump to content
Sign in to follow this  
water

OutlookEX UDF - Help & Support

Recommended Posts

Hi Autobot, hi Syed,

after a bit of testing I came up with the following solution (works for me with Windows 7 Service Pack 1 64 bit and Outlook 2010 32 bit) for the new OutlookEX UDF.

Please add the following two lines to the end of _OL_Open:

; The following statement just makes sure Outlook is up and running and a session has been established
$oOL.GetNameSpace("MAPI").Offline
Return $oOL ; <== This line already exists

Could you please do some testing with Outlook not running when you start a script and post the results?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hi Syed,

I've tested on Windows XP SP3 with Outlook 2002 and on Windows 7 SP1 with Outlook 2010.

On both machines Windows 7 with Outlook 2010 it works when Outlook is already running and doesn't if I don't wait for Outlook to come up.

Edit:

On Windows XP SP3 with Outlook 2002 it doesn't matter if Outlook is running or not - _OL_MailSend always works.

Hi Water,

I tried in Windows XP SP3 with Outlook 2007 by setting sleep of 5000 but still i am getting the same messages!


Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites

Hi Syed,

could you please try to insert the two lines I mentioned in my previous post?

They solved the problem with Outlook 2010 for me.

Please test and report the results here.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hi Syed,

I've tested on Windows XP SP3 with Outlook 2002 and on Windows 7 SP1 with Outlook 2010.

On both machines Windows 7 with Outlook 2010 it works when Outlook is already running and doesn't if I don't wait for Outlook to come up.

Edit:

On Windows XP SP3 with Outlook 2002 it doesn't matter if Outlook is running or not - _OL_MailSend always works.

Hi Water,

I tried this option on both Windows 7 with Outlook 2010 and Windows XP SP3 with Outlook 2007. Both did not work.Still i am getting the same error message! Do you want me to try something else ?


Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites

I've inserted the code to logon with the default profile. As I can't test at the moment I'm not sure about the syntax. Please use One of the two described Logon statements at the end of the function.

Please replace _OL_Open with this code:

Func _OL_Open($fOL_WarningClick = False, $sOL_WarningProgram = "", $iOL_WinCheckTime = 1000, $iOL_CtrlCheckTime = 1000) 
 
    If Not IsBool($fOL_WarningClick) Then Return SetError(3, 0, 0) 
    If Not IsInt($iOL_WinCheckTime) Then Return SetError(4, 0, 0) 
    If Not IsInt($iOL_CtrlCheckTime) Then Return SetError(7, 0, 0) 
    If $fOL_WarningClick Then 
        If $sOL_WarningProgram = "" Then $sOL_WarningProgram = @ScriptDir & "\_OL_Warnings.exe" 
        If Not FileExists($sOL_WarningProgram) Then Return SetError(1, 0, 0) 
        Run($sOL_WarningProgram & " " & @AutoItPID & " " & $iOL_WinCheckTime & " " & $iOL_CtrlCheckTime, "", @SW_HIDE) 
        If @error <> 0 Then Return SetError(6, @error, 0) 
    EndIf 
    If ProcessExists("Outlook.exe") > 0 Then $fOL_AlreadyRunning = True 
    Local $oOL = ObjCreate("Outlook.Application") 
    If @error <> 0 Or Not IsObj($oOL) Then Return SetError(1, @error, 0) 
    ; A COM error handler will be initialised only if one does not exist 
    If ObjEvent("AutoIt.Error") = "" Then 
        $oOL_Error = ObjEvent("AutoIt.Error", "_OL_Error") ; Creates a custom error handler 
        If @error <> 0 Then Return SetError(2, @error, 0) 
    EndIf
    ; Logon to the default profile if Outlook wasn't already running
    If $fOL_AlreadyRunning = False Then
        Local $oOL_Namespace = $oOL.GetNamespace("MAPI")
        $oOL_Namespace.Logon()      ; <== If this doesnt work please try: $oOL_Namespace.Logon("", "", Default, Default)
        If @error <> 0 Then Return SetError(8, @error, 0)
    EndIf 
    Return $oOL 
 
EndFunc   ;==>_OL_Open
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I run Windows 7 and Office 2010 and it works OK.

I have a slightly modified script

I don't have this line as exist in the example script

Global $sCurrentUser = $oOutlook.GetNameSpace("MAPI").CurrentUser.Name

Instead I send directly to a username and it works nice.

Share this post


Link to post
Share on other sites

Hi Water,

i have tested this script on Windows XP SP3 with outlook 2007 where it works fine both the scenario of outlook openend and not opened. But in Windows 7 with outlook 2010 machine i am getting a below attached messages. I don't know whats the issue i have :)

Note:

in profile list i am getting below 2 profile ID's.

1. Default.

2. xx3200


Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites

Please replace the logon line with

$oOL_Namespace.Logon("", "", False, False)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Same error messages and the selection dialog? Or different?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

only the same error messages! no selection dialog this time :)

So the login works :)

I will have to create a test script when I'm at my windows PC tomorrow.

I will post what I have as soon as possible.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hi Autobot,

put a Sleep for a few seconds (>10) after _OL_Open and see if the problem persists.

In addition you can set $iOL_Debug = 2 before _OL_Open.

If you get 0x80004004 (Operation aborted) you have the same problem we are investigating at the moment.

What Windows do you run, what Outllok do you run?

Sorry did not get the rest until now. 10 Sec wait after _OL_Open cured it though.

To explain I can loop the itemfine around and around without the wait but it dies as soon as a new item is introduced to the folders being searched.

Share this post


Link to post
Share on other sites

Ok, this should work with Outlook 2007 and Outlook 2010:

Func _OL_Open($fOL_WarningClick = False, $sOL_WarningProgram = "", $iOL_WinCheckTime = 1000, $iOL_CtrlCheckTime = 1000)

    If Not IsBool($fOL_WarningClick) Then Return SetError(3, 0, 0)
    If Not IsInt($iOL_WinCheckTime) Then Return SetError(4, 0, 0)
    If Not IsInt($iOL_CtrlCheckTime) Then Return SetError(7, 0, 0)
    If $fOL_WarningClick Then
        If $sOL_WarningProgram = "" Then $sOL_WarningProgram = @ScriptDir & "\_OL_Warnings.exe"
        If Not FileExists($sOL_WarningProgram) Then Return SetError(1, 0, 0)
        Run($sOL_WarningProgram & " " & @AutoItPID & " " & $iOL_WinCheckTime & " " & $iOL_CtrlCheckTime, "", @SW_HIDE)
        If @error <> 0 Then Return SetError(6, @error, 0)
    EndIf
    If ProcessExists("Outlook.exe") > 0 Then $fOL_AlreadyRunning = True
    Local $oOL = ObjCreate("Outlook.Application")
    If @error <> 0 Or Not IsObj($oOL) Then Return SetError(1, @error, 0)
    ; A COM error handler will be initialised only if one does not exist
    If ObjEvent("AutoIt.Error") = "" Then
        $oOL_Error = ObjEvent("AutoIt.Error", "_OL_Error") ; Creates a custom error handler
        If @error <> 0 Then Return SetError(2, @error, 0)
    EndIf
    ; Logon to the default profile if Outlook wasn't already running
    If $fOL_AlreadyRunning = False Then
        Local $oOL_Namespace = $oOL.GetNamespace("MAPI")
        $oOL_Namespace.Logon($oOL.DefaultProfileName, "", False, False)
        If @error <> 0 Then Return SetError(8, @error, 0)
    EndIf
    Return $oOL

EndFunc   ;==>_OL_Open

Could you please close Outlook and then run this little test script:

#include <OutlookEx.au3>
; Open the connection to Outlook
$iOL_Debug = 2
Global $oOL = _OL_Open()
ConsoleWrite(@error & @CRLF)
ConsoleWrite($oOL.GetNameSpace("MAPI").CurrentUser.Name & @CRLF)

The SciTe console should show:

0
<The name of the current Outlook user>

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I added "$oOL.GetNameSpace("MAPI").Offline" to my code and it works very nice in Win 7 and Outlook 2010 english version both, fully patched.

Global $oOL = _OL_Open()
$oOL.GetNameSpace("MAPI").Offline
$sUser = $oOL.GetNameSpace("MAPI").CurrentUser.Name

Share this post


Link to post
Share on other sites

Ok, this should work with Outlook 2007 and Outlook 2010:

Func _OL_Open($fOL_WarningClick = False, $sOL_WarningProgram = "", $iOL_WinCheckTime = 1000, $iOL_CtrlCheckTime = 1000)

    If Not IsBool($fOL_WarningClick) Then Return SetError(3, 0, 0)
    If Not IsInt($iOL_WinCheckTime) Then Return SetError(4, 0, 0)
    If Not IsInt($iOL_CtrlCheckTime) Then Return SetError(7, 0, 0)
    If $fOL_WarningClick Then
        If $sOL_WarningProgram = "" Then $sOL_WarningProgram = @ScriptDir & "\_OL_Warnings.exe"
        If Not FileExists($sOL_WarningProgram) Then Return SetError(1, 0, 0)
        Run($sOL_WarningProgram & " " & @AutoItPID & " " & $iOL_WinCheckTime & " " & $iOL_CtrlCheckTime, "", @SW_HIDE)
        If @error <> 0 Then Return SetError(6, @error, 0)
    EndIf
    If ProcessExists("Outlook.exe") > 0 Then $fOL_AlreadyRunning = True
    Local $oOL = ObjCreate("Outlook.Application")
    If @error <> 0 Or Not IsObj($oOL) Then Return SetError(1, @error, 0)
    ; A COM error handler will be initialised only if one does not exist
    If ObjEvent("AutoIt.Error") = "" Then
        $oOL_Error = ObjEvent("AutoIt.Error", "_OL_Error") ; Creates a custom error handler
        If @error <> 0 Then Return SetError(2, @error, 0)
    EndIf
    ; Logon to the default profile if Outlook wasn't already running
    If $fOL_AlreadyRunning = False Then
        Local $oOL_Namespace = $oOL.GetNamespace("MAPI")
        $oOL_Namespace.Logon($oOL.DefaultProfileName, "", False, False)
        If @error <> 0 Then Return SetError(8, @error, 0)
    EndIf
    Return $oOL

EndFunc   ;==>_OL_Open

Could you please close Outlook and then run this little test script:

#include <OutlookEx.au3>
; Open the connection to Outlook
$iOL_Debug = 2
Global $oOL = _OL_Open()
ConsoleWrite(@error & @CRLF)
ConsoleWrite($oOL.GetNameSpace("MAPI").CurrentUser.Name & @CRLF)

The SciTe console should show:

0
<The name of the current Outlook user>

Yes! you are correct! this returned the value 0 and the current user name

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites

Fine - so we got the start and login part right! Now we need to check why you get this other error messages!

Can you post your script (if it's short) or create a reproducer script so whe have something simple to test with?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Fine - so we got the start and login part right! Now we need to check why you get this other error messages!

Can you post your script (if it's short) or create a reproducer script so whe have something simple to test with?

i am using the same example what you have given above. For your reference i have posted the example as well the UDF below!

#include <OutlookEX.au3>

$iOL_Debug = 2 ; <==This line has been moved

Global $oOutlook = _OL_Open()

$oOutlook.GetNameSpace("MAPI").Offline

;$sUser = $oOutlook.GetNameSpace("MAPI").CurrentUser.Name

; *****************************************************************************

; Example 1

; Send an html mail to the current user.

; Add an attachment and set importance to high.

; *****************************************************************************

Global $sCurrentUser = $oOutlook.GetNameSpace("MAPI").CurrentUser.Name

_OL_MailSend($oOutlook, "TestSubject", "Body<br><b>fett</b> normal.", $sCurrentUser, @ScriptDir & "\_OL_MailSend.au3", $olImportanceHigh, $olFormatHTML)

If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_MailSend Example Script", "Error sending mail. @error = " & @error & ", @extended: " & @extended)

MsgBox(64, "OutlookEX UDF: _OL_MailSend Example Script", "Mail successfully sent to user '" & $sCurrentUser & "'!")


Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites

Hi Syed,

thanks for the reply!

I'm off for a few days and might respond on Saturday (depending on the weather).

Do you connect to an Exchange server? If yes, which version?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-11-30 - Version 1.4.0.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hi Syed,

thanks for the reply!

I'm off for a few days and might respond on Saturday (depending on the weather).

Do you connect to an Exchange server? If yes, which version?

yes.I conncect Exchagne server version 2010!


Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×
×
  • Create New...