Jump to content

OutlookEX UDF - Help & Support


Recommended Posts

What do you get when you check @error and @extended after calling _OL_Open?

$oOL = _OL_Open()
MsgBox(0, "", "@error: " & @error & ", @extended: " & @extended)
_OL_Wrapper_SendMail($oOL, $guiControlArray[$p][$EmailAddress], "", "", $clipboard, "", $olFormatHTML, $olImportanceNormal)

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

More Details

I made a cut down example to demo the problem

#include <OutlookEX.au3>
Local $TO = "[email="email@gmail.com"]email@gmail.com[/email]"
Local $CC = ""
Local $BCC = ""
Local $Subject = "Change Of Address"
Local $Body = "This is the Body of the Email"
Local $Attachments = ""
Local $HTMLFormat = $olFormatHTML
Local $Importance = $olImportanceNormal

$oOL = _OL_Open()
MsgBox(0, "DEBUG", "Email Address=" & $TO)
MsgBox(0, "DEBUG", "Subject=" & $Subject)
MsgBox(0, "DEBUG", "Body=" & $Body)
MsgBox(0, "DEBUG", "Format=" &$HTMLFormat)
MsgBox(0, "DEBUG", "Importance=" & $olImportanceNormal)
;_OL_Wrapper_SendMail($oOL[, $sTo = ""[, $sCc= ""[, $sBCc = ""[, $sSubject = ""[, $sBody = ""[, $sAttachments = ""[, $iBodyFormat = $olFormatUnspecified[, $iImportance = $olImportanceNormal]]]]]]]])
 _OL_Wrapper_SendMail($oOL, $TO, $CC, $BCC, $Subject, $Body, $Attachments, $HTMLFormat, $Importance)
MsgBox(0, "Debug", "SendMail Error=" & @error)

I'm running on W7 64bit. Outlook is version 2010 both fully patched.

The full error message is

C:LocalChangeOfAddressOutlookEX.au3 (983) : ==> Variable must be of type "Object".:

Local $oOL_Namespace = $oOL.GetNamespace("MAPI")

Local $oOL_Namespace = $oOL^ ERROR

->16:57:01 AutoIT3.exe ended.rc:1

>Exit code: 1 Time: 10.619

Hope this helps.

David

Link to comment
Share on other sites

Do you run the 32 or 64 bit version of Outlook?

Do you compile your AutoIt script for 32 or 64 bit?

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

The error you see on line 983 is in function _OL_Wrapper_SendMail where _OL_FolderAccess is called. That's the first call of a Outlook function after _OL_Open.

The problems seems to be with _OL_Open.

To track down the problem I need the @error and @extended of _OL_Open as posted above.

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

Here is the reproducer. Insert a valid or invalid address and it should send the mail as soon as all recipients are correct.

A bit complext - but I will have a look and hope to make it a bit easier:

#include <OutlookEX.au3>

Global $stringSendTo = "valid address or invalid address"
Global $bInvalidRecipients = True, $aRecipCheck, $oRecipSelect
$oOutlook = _OL_Open()
$oItem = _OL_ItemCreate($oOutlook, $olMailItem, "*Outlook-UDF-TestTargetFolderMail", "", "Subject=TestMail", "BodyFormat=" & $olFormatHTML, "HTMLBody=Bodytext in <b>bold</b>")
If @error <> 0 Then Exit MsgBox(16, "Error", "Error returned by _OL_ItemCreate. @error = " & @error & ", @extended = " & @extended)
$aRecipCheck = _OL_ItemRecipientCheckEX($oOutlook, $stringSendTo)
$bInvalidRecipients = False
For $i = 1 To $aRecipCheck[0][0]
If $aRecipCheck[$i][1] = False Then $bInvalidRecipients = True
Next
If $bInvalidRecipients Then
$oItem.Display
$oRecipSelect = _OL_ItemRecipientSelect($oOutlook, $stringSendTo, $olTo, True)
If Not IsArray($oRecipSelect) Then Exit
If @error <> 0 Then Exit MsgBox(16, "Error", "Error returned by _OL_ItemRecipientSelect. @error = " & @error & ", @extended = " & @extended)
_OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olTo, $oRecipSelect)
If @error <> 0 Then Exit MsgBox(16, "Error", "Error returned by _OL_RecipientAdd. @error = " & @error & ", @extended = " & @extended)
Else
For $i = 1 To $aRecipCheck[0][0]
_OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olTo, $aRecipCheck[$i][2])
If @error <> 0 Then Exit MsgBox(16, "Error", "Error returned by _OL_RecipientAdd. @error = " & @error & ", @extended = " & @extended)
Next
EndIf
_OL_ItemSend($oOutlook, $oItem)
If @error <> 0 Then Exit MsgBox(16, "Error", "Error returned by _OL_ItemSend. @error = " & @error & ", @extended = " & @extended)
_OL_Close($oOutlook)

Thanks water

Unfortunately the same problem occurs.

Steps to reproduce =

- (run reproducer script)

- MailItem is displayed

- Global Address List is displayed with $stringSendTo displayed in 'To' field

- Click 'Ok' in Global Address List

- 'Check Names' dialogue appears with two entries

- Required entry selected and 'Ok' clicked

- _OL_ItemSend returns @error = 2 @ extended = -2147352567

Link to comment
Share on other sites

Strange. I did the same and the message was successfully sent. Please see the attached screenshots.

What type of address entry do you select? What do you get when you right click the address you want to select in the "Check names" dialog and select "Properties". What's the content of the E-mail tab?

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

One quick thing I have noticed - in your reproducer script there is a line:

$aRecipCheck = _OL_ItemRecipientCheckEX($oOutlook, $stringSendTo)

The function you posted earlier was called _OL_ItemRecipientCheck. I had to change _OL_ItemRecipientCheckEx to _OL_ItemRecipientCheck to get the reproducer script to work. Was this just a typo or am I missing a new version of the function?

To answer your post....

I'm selecting a person rather than a resource. The content of the email tab is long, listing the various email domains we use (it would appear that firstname.surname@domain.com is valid for all the domains we use).

e.g.

smtp:firstname.surname@domain1.com

smtp:firstname.surname@domain2.com

etc

Interestingly if I follow the steps below, the email resolves ok sometimes and doesn't resolve other times:

- when 'select names' dialog appears, rather than clicking Ok, type $stringSendTo value in to box

- double click correct name from resulting list

- name is resolved successfully in 'To' field (along with unresolved name passed by $stringSendTo

- delete unresolved name from 'To' field

- click 'Ok'

$iOL_Debug = 2 reports 'Outlook does not recognize one or more names'.

Additionally, bizarrely, when the 'check names' dialog appears, if I click the other name, then click back on the correct name the email resolves ok - very strange behaviour!

Link to comment
Share on other sites

I had to change _OL_ItemRecipientCheckEx to _OL_ItemRecipientCheck to get the reproducer script to work.

That's fine. I had already pasted the functions to the UDF but to test the reproducer script (including the functions) I had to rename them.

As sometimes the address resolves and sometimes it doesn't I get the impression that it can't be related to the AutoIt function but has to be caused by the recipients data or Outlook itself :huh:

I think we need to verify the result before sending the mail.

I will think about a few tests and post the code ...

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,

Thanks for taking the time to look into this.

Do you run the 32 or 64 bit version of Outlook?

Do you compile your AutoIt script for 32 or 64 bit?

AND

The error you see on line 983 is in function _OL_Wrapper_SendMail where _OL_FolderAccess is called. That's the first call of a Outlook function after _OL_Open.

The problems seems to be with _OL_Open.

To track down the problem I need the @error and @extended of _OL_Open as posted above.

Outlook runs from here C:Program FilesMicrosoft OfficeOffice14 not the C:Program Files (x86) folder so that tells me it is the 64bit version.

I have been compiling in 32bit. I just compiled in 64bit and a program named TestEmail_x64.exe was created. This generated the same error message.

I don't know how to catch the values of @error and @extended from _OL_Open

Can you give me a point in the right direction please?

Thanks

David

Link to comment
Share on other sites

Hi Water,

Thanks for taking the time to look into this.

Outlook runs from here C:Program FilesMicrosoft OfficeOffice14 not the C:Program Files (x86) folder so that tells me it is the 64bit version.

I have been compiling in 32bit. I just compiled in 64bit and a program named TestEmail_x64.exe was created. This generated the same error message.

I don't know how to catch the values of @error and @extended from _OL_Open

Can you give me a point in the right direction please?

Thanks

David

I had a bit of a think about returning the error codes and I was probably making it harder than it needed to be.

I added the following line of code direclty after the _OL_Open line

$oOL = _OL_Open()

Msgbox (0,"DEBUG", "OL_Open Status (@error, @extended)=" & @error & "," & @extended)

64bit exe reported the follwoing values

@error = 1 and @extended = -2147221005

32bit exe reported the same values.

Hope this helps diagnose the problem

David

Link to comment
Share on other sites

I had a bit of a think about returning the error codes and I was probably making it harder than it needed to be.

A little more diagnosis.

I added the following Message Boxes to OutlookEX.au3 as follows (around line 176)

Func _OL_Open($bOL_WarningClick = False, $sOL_WarningProgram = "", $iOL_WinCheckTime = 1000, $iOL_CtrlCheckTime = 1000, $sOL_ProfileName = "", $sOL_Password = "")
Local $iOL_ErrorHandler = 0
Local $oOL = ObjGet("", "Outlook.Application")
Msgbox (0,"OutlookEX.au3", "OL_Open Status (@error, @extended)=" & @error & "," & @extended)
MsgBox(0,"OutlookEX.au3","Outlook Already Running ($oOL 0=Not Running)=" &"'" & $oOL &"'")

Both 32 and 64 bit test.exe's produce the same results when Outlook is open or closed.

The first message box reports -2147221005,0

The second message box reports that $oOL is blank. (i.e. to single quotes togeather)

Link to comment
Share on other sites

The error you get is "CO_E_CLASSSTRING - Invalid class string (0x800401F3)".

Can you replace "Outlook.Application" with "Outlook.Application.14" in the ObjGet statement?

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

The error you get is "CO_E_CLASSSTRING - Invalid class string (0x800401F3)".

Can you replace "Outlook.Application" with "Outlook.Application.14" in the ObjGet statement?

Hi Water,

I made the above change and we are making progress. It now works if Outlook is already running.

If Outlook isn't running my message boxes report the following .

MsgBox From OutlookEX.au3

OL_OPEN Status @error,@extended = -2147221021 , 0

Outlook Already Running = '' (that is two single quotes togeather.)

MsgBos From TestEmail.au3

OL_Open Status @error,@extended = 1, -2147221005

AutoIt Error

Line 5068 (File "<path to executable>")

Error Variable must be of type "Object".

Both 32 and 64bit compiles produce the same errors.

I spotted this code further down in OUtlookEX.au3

If Not $bOL_AlreadyRunning Then

$oOL = ObjCreate("Outlook.Application")

And I also changed Outlook.Application to Outlook.Application.14

Now it seems to work perfectly.

I guess now you need to figure out how to make the code generic for different versions of outlook. :)

Hope this helps. Let me know if you would like me to assist in testing future versions.

Thanks

David

Link to comment
Share on other sites

Hi David,

I'm running Windows 7 64 bit and Outlook 2010 32 bit here. Using "Outlook.Application" works fine here.

Do you have another PC with Windows 7 and Outlook 2010 you can test? Maybe it's just an installation problem.

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

I have another machine at the office I can try. (again W7 64bit and Office 10 64bit)

I'll have to take the .14's back out and recompile.

I'll see if I can get to it tomorrow :)

I'll post back here with my results.

Thanks

David

Link to comment
Share on other sites

I don't believe it. I changed the OutlookEX.au3 file back to it's original state and It works on the other machine at the office.

(and fails on my development machine)

So something must be wrong with my local install of MS Office 10

Link to comment
Share on other sites

That's what I suspected. Glad the problem could be solved :)

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

:D

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

water

I have a need to save attachments from a Mail Item where the attachment is a 'true' attachment, rather than an 'inline' attachment e.g. a picture within the html body. I've used Outlook Spy to determine that the property tags that distinguish the two types are PR_ATTACH_FLAGS and PR_ATTACHMENT_HIDDEN.

PR_ATTACH_FLAGS = 4 for an 'inline' attachment, 0 for a true attachment

PR_ATTACHMENT_HIDDEN = true for 'inline' attachment, false for a 'true' attachment

I've had a look at _OL_ItemSave with a view to update it (i discounted _OL_ItemAttachmentGet as I will have attachments with the same filename) however i'm stuck on how to add the IF statement that would only save the 'true' attachments.

Would you be willing to help?

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...