Jump to content

OutlookEX UDF - Help & Support (III)


water
 Share

Recommended Posts

OK.
Could you then please run function _OL_ItemRecipientCheck and check the returned array?

$aResult = _OL_ItemRecipientCheck($oOL, $oSSO)
If $aResult[1][1] = True Then
    _OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, $aResult[1][2])
Else
    Exit MsgBox(0, "Error", "Could not resolve recipient!")
EndIf


 

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

OK.
Could you then please run function _OL_ItemRecipientCheck and check the returned array?

$aResult = _OL_ItemRecipientCheck($oOL, $oSSO)
If $aResult[1][1] = True Then
    _OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, $aResult[1][2])
Else
    Exit MsgBox(0, "Error", "Could not resolve recipient!")
EndIf


 

 

Did this, and ​I actually get the error window as before (the debug code) however the code you provided doesn't show a message box. I would assume this to be indicative of the recipient being added successfully, and thus changed my code to the following. This actually spawns a message box stating that the recipient was added.

#include <includes\OutlookEx\OutlookEx.au3>
;#include <debug.au3>
;_DebugSetup()
;_DebugCOMError()

; Open the connection to Outlook
Global $oOL = _OL_Open(), $vSSO = "000000000"

; Create a mail item and set some properties
Global $oItem = _OL_ItemCreate($oOL, $olMailItem, "*\Drafts", "", "Subject=Test Message", "BodyFormat=" & $olFormatHTML, "HTMLBody=Please disregard.")

; Add a recipient and resolve it
$aResult = _OL_ItemRecipientCheck($oOL, $vSSO)
If $aResult[1][1] = True Then
    _OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, $aResult[1][2])
    MsgBox(0, "Success", "Recipient resolved!")
Else
    MsgBox(0, "Error", "Could not resolve recipient!")
    Exit
EndIf

; Send the mail
;_OL_ItemSend($oOL, $oItem)
$oItem.Send()

; Close the object
_OL_Close($oOL)

 

I got curious about this and added Sleep(5000) between adding a recipient and actually sending the email, thinking maybe that the script was just running "too fast". No such luck.

Figured it was worth mentioning that when I run the script once (open Outlook, compose a message, add a recipient, attempt to send it, and fail) and repeat those steps again, the second email sends successfully. It's almost as if the fact that I have an email in the Drafts folder causes it to work. Still no clue as to what is causing this. It's all very strange, and very specific to the case (where users with one letter in the last name fail, but not others).

 

Thanks again for your help.

AutoIt Stuff:

 

UDFs: {Grow}

Link to comment
Share on other sites

I really do not understand what causes the problem.
The function _OL_ItemRecipientAdd uses the CreateRecipient method which accepts the display name, the alias, or the full SMTP e-mail address of the recipient.
So everything seems to work fine until the script tries to send the mail.
The recipient is being resolved using the alias. So it shouldn't matter if the lastname has one, two or more characters ...

Very, very strange. I need to think about it :'(

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

  • 1 month later...

Good Morning All,

I have Outlook 2013 and Windows 7 x64. Trying to automatically send email using your OutlookEX. I have version 1.0.0.0. 

"Error creating a connection to Outlook. @error = 1, @extended = -2147221164"

I see from the topic - this is an error that was experienced before...
"

The error code stands for '80040154 Class not registered'.

Means: The class is unknown to the user running the script. I assume you use the system account to run the script in the task scheduler?

"

I was running the script as an administrator - do I have to run it as the person's who's email is open? I have to sign into Outlook every time I run it - different user / different password.

Thanks!

"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Link to comment
Share on other sites

  • Moderators

@souldjer777, it is a tad difficult to troubleshoot the issue when you don't post any code ;)

Edit: No idea why the forum inserted a picture in my post...

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Sorry about that, I figured someone knew the issue... here's the code I get the error in...

#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
#RequireAdmin
#include <OutlookEX.au3>

Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Example 1
; Send a html mail to the current user.
; Add an attachment and set importance to high.
; *****************************************************************************
Global $sCurrentUser = $oOutlook.GetNameSpace("MAPI").CurrentUser.Name
_OL_Wrapper_SendMail($oOutlook, $sCurrentUser, "", "", "TestSubject", "Body<br><b>fett</b> normal.", @ScriptDir & "\_OL_Wrapper_SendMail.au3", $olFormatHTML, $olImportanceHigh)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OutlookSendMail Wrapper Script", "Error sending mail. @error = " & @error & ", @extended: " & @extended)
MsgBox(64, "OutlookEX UDF: _OutlookSendMail Wrapper Script", "Mail successfully sent to user '" & $sCurrentUser & "'!")

_OL_Close($oOutlook)

Just taking example codes from forums etc... to see if I can get it to work without any tweaks.

Edited by souldjer777

"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Link to comment
Share on other sites

If it helps, I get another error...

>Running AU3Check (3.3.14.0)  params:-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6  from:C:\Program Files (x86)\AutoIt3  input:C:\temp\send_email_error_checking_02.au3
+>08:32:46 AU3Check ended.rc:0
>Running:(3.3.14.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\temp\send_email_error_checking_02.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
"C:\temp\send_email_error_checking_02.au3" (30) : ==> Variable must be of type "Object".:
Global $sCurrentUser = $oOutlook.GetNameSpace("MAPI").CurrentUser.Name
Global $sCurrentUser = $oOutlook^ ERROR
->08:33:17 AutoIt3.exe ended.rc:1
+>08:33:17 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 31.69

from code...

#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=N
#include <File.au3>
#include <GUIConstants.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <Array.au3>
#include <Constants.au3>
#include <Date.au3>
#include <WinAPIFiles.au3>
#include <ScreenCapture.au3>
#include <OutlookEX.au3>
#include <WinAPIFiles.au3>



Global $iFileName, $Form1_1
Global $oOutlook = _OL_Open()
GLobal $sTo = "emailaddress@gmail.com;"

$Form1_1 = GUICreate("System Information", 1083, 638, 182, 114)
GUISetState(@SW_SHOW)

If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)

$iFileName = @DesktopDir & "\Utility Screenshot - " & @MON & "." & @MDAY & "." & @YEAR & " - (" & @HOUR & "." & @MIN & "." & @SEC & ").jpg"
_ScreenCapture_CaptureWnd($iFileName, $Form1_1)

Global $sCurrentUser = $oOutlook.GetNameSpace("MAPI").CurrentUser.Name
_OL_Wrapper_SendMail($oOutlook, $sTo, "", "", "Configuration Utility Screenshot", "Attached please find the Configuration Utilty Screenshot.<br>Automatically sent via the Configuration Utlity<br>Thank you, <br>" & $sCurrentUser, $iFileName, $olFormatHTML, $olImportanceHigh)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OutlookSendMail Wrapper Script", "Error sending mail. @error = " & @error & ", @extended: " & @extended)
MsgBox(64, "OutlookEX UDF: _OutlookSendMail Wrapper Script", "Mail successfully sent to user '" & $sCurrentUser & "'!")

_OL_Close($oOutlook)

Again, just testing code already in this forum.

"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Link to comment
Share on other sites

Trying different computers... W7 x64 Outlook 2013 x64

OutlookEX UDF: _OutlookSendMail Wrapper Script
"Error sending mail. @error = 5004, @extended: 0"

I am using a Shared Mailbox as the default mail profile.

Edited by souldjer777

"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Link to comment
Share on other sites

Okay... oddly enough, I've gotten the following script to work in Outlook 2013 by ONLY connecting to the Shared Inbox :dance: I get a bunch of "safety" prompts but it goes through!!! All good I guess! I'll delete content from my previous posts to not clutter the forums.
 

#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=N
#RequireAdmin
#include <File.au3>
#include <GUIConstants.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <Array.au3>
#include <Constants.au3>
#include <Date.au3>
#include <WinAPIFiles.au3>
#include <ScreenCapture.au3>
#include <OutlookEX.au3>
#include <WinAPIFiles.au3>



Global $iFileName, $Form1_1
Global $oOutlook = _OL_Open()
GLobal $sTo = "emailaddress@gmail.com;"

$Form1_1 = GUICreate("System Information", 1083, 638, 182, 114)
GUISetState(@SW_SHOW)

If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)

$iFileName = @DesktopDir & "\Utility Screenshot - " & @MON & "." & @MDAY & "." & @YEAR & " - (" & @HOUR & "." & @MIN & "." & @SEC & ").jpg"
_ScreenCapture_CaptureWnd($iFileName, $Form1_1)

Global $sCurrentUser = $oOutlook.GetNameSpace("MAPI").CurrentUser.Name
_OL_Wrapper_SendMail($oOutlook, $sTo, "", "", "Configuration Utility Screenshot", "Attached please find the Configuration Utilty Screenshot.<br>Automatically sent via the Configuration Utlity<br>Thank you, <br>" & $sCurrentUser, $iFileName, $olFormatHTML, $olImportanceHigh)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OutlookSendMail Wrapper Script", "Error sending mail. @error = " & @error & ", @extended: " & @extended)
MsgBox(64, "OutlookEX UDF: _OutlookSendMail Wrapper Script", "Mail successfully sent to user '" & $sCurrentUser & "'!")

_OL_Close($oOutlook)

 

"Maybe I'm on a road that ain't been paved yet. And maybe I see a sign that ain't been made yet"
Song Title: I guess you could say
Artist: Middle Class Rut

Link to comment
Share on other sites

Please have a look at the wiki. It describes how to start Outlook and how to handle those pop up messages. 

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

Is anyone interested in functions to work with Outlook "conversations"?
You should be able to gather and manipulate items (mails, appointments etc.) which belong to the same conversation.

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

  • 2 weeks later...

Not with the OutlookEX UDF.

But you could try to set a Registry key as described here. I've never done it myself so be careful!

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's not exactly that. 

It's a registry edit to force all new message to use the default email account in a special configuration: one pop3 account and an imap/exchange account.

The imap and exchange account don't use the default email account defines in outlook.

The registry key force to use this parameters even if they are a imap/exchange account.

 

me, i just want change the default account :)

 

Link to comment
Share on other sites

Which version of Outlook do you run?

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

Unfortunately I have absolutely no idea how to help with this issue :(

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

an solution by registery edit

full solution https://www.autoitscript.fr/forum/viewtopic.php?f=3&t=13778

 

#Include <Array.au3> ; uniquement pour _ArrayDisplay

$aAccounts = _OutlookGetAccounts()
_ArrayDisplay($aAccounts)

_OutlookSetAccountDefault("NomDuCompte")


Func _OutlookSetAccountDefault($vAccount) ; $vAccount peut etre le nom du compte ou son identifiant dans la base de registre
    Local $aAccounts
    Local $sAccountID = $vAccount
    
    If Not Number($vAccount) Then
        $aAccounts = _OutlookGetAccounts()
        _ArrayDisplay($aAccounts)
        For $i = 1 To $aAccounts[0][0]
            If $aAccounts[$i][1] = $vAccount Then
                $sAccountID = $aAccounts[$i][0]
                ExitLoop
            EndIf
        Next
        If Not Number($sAccountID) Then Return SetError(1, 0, 0)
    EndIf
    
    Local $sOrder = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook\9375CFF0413111d3B88A00104B2A6676", "{ED475418-B0D6-11D2-8C3B-00104B2A6676}")
    Local $sAccountReverse = StringRegExpReplace($sAccountID, "(\d{2})(\d{2})(\d{2})(\d{2})", "$4$3$2$1")
    Local $sNewOrder = StringRegExpReplace($sOrder, "^0x\K((?:\d{8})*)" & $sAccountReverse, $sAccountReverse & "$1")
    Local $iRet = RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook\9375CFF0413111d3B88A00104B2A6676", "{ED475418-B0D6-11D2-8C3B-00104B2A6676}", "REG_BINARY", $sNewOrder)
    Return SetError(@error, 0, $iRet)
EndFunc


Func _OutlookGetAccounts()
    Local $sOrder = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook\9375CFF0413111d3B88A00104B2A6676", "{ED475418-B0D6-11D2-8C3B-00104B2A6676}")
    Local $aNums = StringRegExp($sOrder, "\d{8}", 3)
    Local $aRet[UBound($aNums) + 1][2]

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...