Jump to content

OutlookEX UDF - Help & Support (II)


water
 Share

Recommended Posts

Return Code for Outlook :(

 

I have a script that copies Outlook.PRF files from a network share and dumps them onto a local directory (C:temp) -

Second part of the script then imports the file from the "temp" path - outlook.exe /importprf C:TempOutlook.PRF   (works a treat)

The problem I'm having is I think the above path doesnt return any "Return Code" and this doesnt allow the remaining script to carry on.

Does that make sence? - Not sure if its a Outlook issue

Link to comment
Share on other sites

Can you please post the code you use to call Outlook?

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

 

Link to comment
Share on other sites

I need to send a e-mail to someone in the company using a script.  The issue I am having is this person's SMTP account is coming back as user can not be found.  if I enter his smtp address in outlook, it automatically changes to his displayname and it sends.

I'm using _OL_Wrapper_SendMail, so I can attach a file.  everyone else smtp address is working.

Is there a way to do a global address book lookup by smtp, and use that address since my guess that's what outlook is doing.

but I really do not know.

It does look like if I use my personal E-mail address and send something to his SMTP address it will get to him.  So it has to be something within our Outlook configuration on his profile.

Any help would be appreciated.

Thank you

Link to comment
Share on other sites

Welcome to AutoIt and the forum!

Which version of the OutlookEX UDF do you use? IIRC there was a bug with an older release when resolving SMTP recipients.

The version can be found in the header of the OutlookEX.au3 file.

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

 

Link to comment
Share on other sites

 Title .........: Microsoft Outlook Function Library (MS Outlook 2003 and later)
; AutoIt Version : 3.3.9.2 (New COM error handler)
; UDF Version ...: 0.9.0
; Language ......: English
; Description ...: A collection of functions for accessing and manipulating Microsoft Outlook
; Author(s) .....: wooltown, water
; Modified.......: 20121007 (YYYYMMDD)

Link to comment
Share on other sites

What is the value of @error and @extended after you have called _OL_Wrapper_SendMail?

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

 

Link to comment
Share on other sites

I'm using Outlook 2010 32bit and autoit is in 32bit mode.

I think it is an internal outlook issue,  if I use the smtp address in outlook, before I send anything it does a Outlook name lookup and converts it and uses exchanges internal mail routing.  if I force it to bounce off the Smtp server by using a smtp type email address, it translates it incorrectly, my guess is the alias has a typo.  To confuse the issue a little further,  everyone has a email address based upon a ntlogin@xxxx.xxxx.com if I send it that address I do not get an error in the script, but I get an email that  outlook sends "Undeliverable: RAP-3/5 Aruba Whitelist - Chelmsford"  

#550 5.1.1 RESOLVER.ADR.RecipNotFound; not found ##

So I think it's just an internal issue,   What are valid email address formats, trying to figure out if I can force it not to use smtp for internal exchange users.   Our local Exchange admin doesn't understand what can possible be the issue and doesn't know how to fix it, so I need to go around it. 

_OL_Wrapper_SendMail($oOutlook, $email_address, $cc_address, "", $Rap & " Aruba Whitelist - Chelmsford", $body, $logdir & $tmp)
 ConsoleWrite(@error & "  " & @extended & @LF)
 ConsoleWrite($email_address & ", " & $cc_address & ", " & "," & $Rap & " Aruba Whitelist - Chelmsford" & ", " & $body & ", " & $logdir & $tmp & @LF)

 

produces this  error log.

 

COM Error Encountered in Aruba_email files.au3
OutlookEx UDF version = 0.9.0
@AutoItVersion = 3.3.8.1
@AutoItX64 = 0
@Compiled = 0
@OSArch = X64
@OSVersion = WIN_7
Scriptline = 3925
NumberHex = 80020009
Number = -2147352567
WinDescription =
Description = Outlook does not recognize one or more names.
Source = Microsoft Outlook
HelpFile =
HelpContext = 0
LastDllError = 0
========================================================
6002  -2147352567
XXXX@XXX.XXXX.com, , ,RAP-3/5 Aruba Whitelist - Chelmsford, Please Process the Enclosed File for managing Aruba Devices attached to the Chelmsford controller, XXXXXXXXXXXXXXIT_UsersXXXXXMy DocumentsInventoryRAP2LogsSent_20130814-ArubaWhitelistBulkAdd_CHELMSFORD.csv
+>09:43:11 AutoIT3.exe ended.rc:0
>Exit code: 0    Time: 4.435

Link to comment
Share on other sites

_OL_Wrapper_SendMail calls some other functions of the UDF under the covers.

The recipient is checked calling _OL_ItemRecipientAdd which doesn't return an error in you case.

The error you see is returned by _OL_ItemSend. This means that Outlook or the Exchange server seems to have a problem resolving the address.

You could try the _OL_ItemRecipientCheck.au3 example script. Replace

$oOutlook.GetNameSpace("MAPI").CurrentUser.Name & ";test.user@google.com"

with your smtp mail address and give it a try.

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

 

Link to comment
Share on other sites

it is weird,   His smtp email  says resolved is true and mail address is the same address displayname is correct.

using his display name it doesn't resolve.   but if I use his display name as the email address in the original code,  it looks like it's working.

strange.

Link to comment
Share on other sites

In my company we have sometimes multiple entries for the same user: "displayname" and "SMS displayname".

This has led to similar problems in the past.

Are there any special characters (Umlauts etc.) in the displayname?

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

 

Link to comment
Share on other sites

no,  just good old english name. 

As long as I can send it, i really do not care, I believe it is a typo somewhere in his outlook profile  but our company is too big to be able to troubleshoot the issue let alone fix it.

:rolleyes: 

Thanks for your help.

Link to comment
Share on other sites

Glad to be of service :D

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

 

Link to comment
Share on other sites

gcue,

did you already find the answer to your question?

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

 

Link to comment
Share on other sites

same script, different problem....When I run the script it works,  when I use Windows 7 task scheduler, it looks like it hangs trying to access outlook.

I am logged in as me,  I force the task scheduler  to log in as me,  but when I log the consolewrites to an inifile, it hangs trying to open outlook.

my computer is set not to sleep, but it will go into screensaver mode, where I have to log back in.

I have 2 scripts that seem to hang when trying to open outlook, when using the task scheduler.   Do you have any idea why and better yet,  suggestions.

Thank you

Link to comment
Share on other sites

Is Outlook running in your logged on user while you test with the task scheduler?

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

 

Link to comment
Share on other sites

outlook GUI is running on multiple machines, this machine is just supposed to be running macros.   

there should be no Outlook GUI running on this machine.  when I test by running the script on this machine.  No Outlook Gui is actively running on that machine,  I can watch what it does on another computer where I monitor the outlook folders.  

This works great if I just run the script.   if I tell task scheduler to run it, it hangs.   I am beginning to hate "Task Scheduler" :)

in the simplest terms here is the code....the only thing that gets logged is:  "Main" when run from task scheduler,  So really It could be the

_OL_Open() or _OL_ItemSendReceive($oOutlook, false)

it's just one of them.

 

main()
_log("exit")

exit

func main()
_log("Main")
Global $oOutlook = _OL_Open()
_OL_ItemSendReceive($oOutlook, false) ; sync up
_log(@error)

endfunc

func _log($temp)
 consolewrite($temp&@lf)
 if not $debug then return
 IniWrite ( "C:TempLog.ini" , @year&@mon&@mday,$temp, "ok" )
 return
EndFunc

Link to comment
Share on other sites

Could you:

  • Insert a '_Log("After _OL_Open")' after _OL_Open so we know where it hangs
  • Replace Consolewrite in _Log with FileWriteLine so we are sure we get all messages
  • Write the value of @Username to the log file as well so we see with which user the script runs

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

 

Link to comment
Share on other sites

sorry it was a hung outlook process, that was hanging it up.  It's back to why somebody's smtp address is not resolving correctly again.

Is there a way to bounce do what _OL_Wrapper_SendMail does,

but to specify an external smtp server.

Link to comment
Share on other sites

The OutlookEX UDF supports all kind of stores Outlook itself supports.

If you create a profile that connects the Outlook client to a POP3/SMTP server you can then specify this profile as parameter for the _OL_Open function.

Never tested it but I think it should work.

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

 

Link to comment
Share on other sites

  • 3 weeks later...

I have a script that watches the sent items folder in outlook and then takes action on an item to save the email to the hard drive.  It works very well, but crashes when I try to send someone an invite to an event from a calendar item.  Apparently the invite email is somehow different in kind and the subroutine cannot handle it.  It returns "Error: the requested action with this object has failed."

Is there a way to test if the object in the sent items folder is an invite so that I can trap this error out?  there will never be a need to save the invite to the hard drive.  I just don't want the script to crash every time I send one.

Here is a simplified version of the script.  Thanks in advance for any help.

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=H:\TMR\Icons\accessories-clock-2.ico
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_Tidy_Stop_OnError=n
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <OutlookEX.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>


;############################## Declare Global Variables ################
Global $DTM_SETFORMAT_, $DateStyle
Global $SaveAttachments = 1


;_OL_ErrorNotify(2)
Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

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 $oOApp = ObjCreate("Outlook.Application")
Global $oItems = $oOApp.GetNamespace("MAPI").GetDefaultFolder($olFolderSentMail).Items
ObjEvent($oItems, "oItems_")
Global $SaveEmail
Global $EmailFileName

While 1
    Sleep(50)
    If WinWaitClose("Microsoft Outlook") Then
        Run("D:\Data\AutoIT Scripts\TMR - Save Sent Emails to TMR and Move from Sent Items.exe")
        Exit
    EndIf
WEnd

Func oItems_ItemAdd($oOL_Item)
    $SaveEmail = MsgBox(4, "TMR - Save Sent Email", "Do you want to Save the Email? --- To: " & $oOL_Item.To & " Subject: " & $oOL_Item.Subject)
EndFunc   ;==>oItems_ItemAdd

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