Jump to content

OutlookEX UDF - Help & Support (IV)


water
 Share

Recommended Posts

Add the following line to your script and check if the body is HTML.

#include <OutlookEx.au3>
; Open the connection to Outlook
Global $oOL = _OL_Open()
; Create a mail item and set some properties
Global $oItem = _OL_ItemCreate($oOL, $olMailItem, "*\Outlook-UDF-Test\TargetFolder\Mail", "", _
  "Subject=TestMail", "BodyFormat=" & $olFormatHTML, "HTMLBody=Bodytext in <b>bold</b>.", "SentOnBehalfOfName=Doe Jane")
; Add a recipient and resolve it
_OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, "Doe John")
$oItem.Display ; <<<<<<<< add this line
; Send the mail
_OL_ItemSend($oOL, $oItem)
If @extended = -2147352567 Then _
  MsgBox(16, "OutlookEX UDF - Example Script", "You don't have permission to send the mail on behalf of the specified person!")
_OL_Close($oOL)

Is there a John or Jane Doe in your company?

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

26 minutes ago, water said:

Add the following line to your script and check if the body is HTML.

#include <OutlookEx.au3>
; Open the connection to Outlook
Global $oOL = _OL_Open()
; Create a mail item and set some properties
Global $oItem = _OL_ItemCreate($oOL, $olMailItem, "*\Outlook-UDF-Test\TargetFolder\Mail", "", _
  "Subject=TestMail", "BodyFormat=" & $olFormatHTML, "HTMLBody=Bodytext in <b>bold</b>.", "SentOnBehalfOfName=Doe Jane")
; Add a recipient and resolve it
_OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, "Doe John")
$oItem.Display ; <<<<<<<< add this line
; Send the mail
_OL_ItemSend($oOL, $oItem)
If @extended = -2147352567 Then _
  MsgBox(16, "OutlookEX UDF - Example Script", "You don't have permission to send the mail on behalf of the specified person!")
_OL_Close($oOL)

Is there a John or Jane Doe in your company?

I can´t see the mail in the testscript and also not in Outlook itself.

 

There is no  John or Jane Doe in my company

Edited by NolleWed
Link to comment
Share on other sites

But I replace in my real script 

$oOutlook = ObjGet("", "Outlook.Application") ; Outlook öffnen

with

$oOutlook= _OL_Open()

and now the Body is filled

I stop the script before the recipient will be added and it works until this point

$oOutlook= _OL_Open()
        
    ;wenn Carrier nicht in Mail-Liste, dann Mail ans PF zur Prüfung, wie bei Neli-Liste
    ;neue E-Mail wird erstellt
    if $CarrierEMail = "nicht gefunden" Then
        $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", "Subject=[AutoIT:ZU PRUEFEN] #abw# weiterversorgen #kurzfristiger Storno# " & $alleNummern & " , " & $relevanteNummer & " , " & $Kundennummer_Wert, "", "SentOnBehalfOfName=ABW-Clearing-D019@telefonica.com")
        $EMail = "ABW-Clearing-D019@telefonica.com"
    Else
        $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", "Subject=#abw# weiterversorgen #kurzfristiger Storno# " & $alleNummern & " , " & $relevanteNummer & " , " & $Kundennummer_Wert, "", "SentOnBehalfOfName=ABW-Clearing-D019@telefonica.com")

        $EMail = $CarrierEMail
    EndIf
    
    ConsoleWrite($EMail & @LF)
    
    $EMailCC = "ABW-Clearing-D019@telefonica.com"
        
    ;neue E-Mail wird angezeigt
    $oItem.display
    $oItem.BodyFormat = $olFormatHTML
    
    ;E-Mailtext wird wird gesucht
    $sBody = $oItem.HTMLBody
    ;die Mail wird befüllt
    $oItem.HTMLBody = $HTMLKDDaten & $sBody

Exit
    _OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olTo, $EMail) ; Empfänger wird gesetzt
    _OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olCC, $EMailCC) ; CC wird gesetzt

    $oItem.send ;Email wird versendet

image.png.c6ba0b7c6d2fb0d00512b65a3a0269ce.png

 

Edited by NolleWed
Link to comment
Share on other sites

Now I stop the script after the recipient will be added but nothing happens

$oOutlook= _OL_Open()
        
    ; wenn Carrier nicht in Mail-Liste, dann Mail ans PF zur Prüfung, wie bei Neli-Liste
    ; neue E-Mail wird erstellt
    if $CarrierEMail = "nicht gefunden" Then
        $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", "Subject=[AutoIT:ZU PRUEFEN] #abw# weiterversorgen #kurzfristiger Storno# " & $alleNummern & " , " & $relevanteNummer & " , " & $Kundennummer_Wert, "", "SentOnBehalfOfName=ABW-Clearing-D019@telefonica.com")
        $EMail = "ABW-Clearing-D019@telefonica.com"
    Else
        $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", "Subject=#abw# weiterversorgen #kurzfristiger Storno# " & $alleNummern & " , " & $relevanteNummer & " , " & $Kundennummer_Wert, "", "SentOnBehalfOfName=ABW-Clearing-D019@telefonica.com")
        $EMail = $CarrierEMail
    EndIf
    
    ConsoleWrite($EMail & @LF)
    
    $EMailCC = "ABW-Clearing-D019@telefonica.com"
        
    ; neue E-Mail wird angezeigt
    $oItem.display
    $oItem.BodyFormat = $olFormatHTML
    
;~  E-Mailtext wird wird gesucht
    $sBody = $oItem.HTMLBody
    ; die Mail wird befüllt
    $oItem.HTMLBody = $HTMLKDDaten & $sBody

    _OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olTo, $EMail) ; Empfänger wird gesetzt
    _OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olCC, $EMailCC) ; CC wird gesetzt
Exit
    $oItem.send ; Email wird versendet

Then I put in _OL_ErrorNotify(2) and get the same Error 

image.png

Edited by NolleWed
Link to comment
Share on other sites

in this testscript

#include <OutlookEx.au3>
_OL_ErrorNotify(2)
; Open the connection to Outlook
Global $oOL = _OL_Open()
; Create a mail item and set some properties
Global $oItem = _OL_ItemCreate($oOL, $olMailItem, "*\Outlook-UDF-Test\TargetFolder\Mail", "", _
  "Subject=TestMail", "BodyFormat=" & $olFormatHTML, "HTMLBody=Bodytext in <b>bold</b>.", "SentOnBehalfOfName=Doe Jane")
; Add a recipient and resolve it
_OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, "Doe John")
$oItem.Display
; Send the mail
_OL_ItemSend($oOL, $oItem)
If @extended = -2147352567 Then _
  MsgBox(16, "OutlookEX UDF - Example Script", "You don't have permission to send the mail on behalf of the specified person!")
_OL_Close($oOL)

I get this Errors in this order, each time I click ok

image.png.f3057c4b9c3146d6a22a82157a4c1271.png

image.png.d18c11bf8c729a104b64df048fe23412.png

image.png.4dfa5359949397fb39d2aa56ac9c73b9.png

image.png.7d40620731b5e8abfab5f36882add320.png

 

image.png.ee92c763dcee30f212c3bd2e8208bd7d.png

 

no mail was created

Edited by NolleWed
Link to comment
Share on other sites

Please add the following line after each call of a _OL_* function. So we know exactly where to search for the problem.

If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error when calling function _OL_*. @error = " & @error & ", @extended = " & @extended)

Please replace _OL_* with the real function you called.

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

7 minutes ago, water said:

Please add the following line after each call of a _OL_* function. So we know exactly where to search for the problem.

If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error when calling function _OL_*. @error = " & @error & ", @extended = " & @extended)

Please replace _OL_* with the real function you called.

You mean this way?

$oOutlook= _OL_Open()
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error when calling function _OL_Open(). @error = " & @error & ", @extended = " & @extended)   
    ; wenn Carrier nicht in Mail-Liste, dann Mail ans PF zur Prüfung, wie bei Neli-Liste
    ; neue E-Mail wird erstellt
    if $CarrierEMail = "nicht gefunden" Then
        $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", "Subject=[AutoIT:ZU PRUEFEN] #abw# weiterversorgen #kurzfristiger Storno# " & $alleNummern & " , " & $relevanteNummer & " , " & $Kundennummer_Wert, "", "SentOnBehalfOfName=ABW-Clearing-D019@telefonica.com")
        If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error when calling function _OL_ItemCreate. @error = " & @error & ", @extended = " & @extended)
        $EMail = "ABW-Clearing-D019@telefonica.com"
    Else
        $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", "Subject=#abw# weiterversorgen #kurzfristiger Storno# " & $alleNummern & " , " & $relevanteNummer & " , " & $Kundennummer_Wert, "", "SentOnBehalfOfName=ABW-Clearing-D019@telefonica.com")
        If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error when calling function _OL_ItemCreate. @error = " & @error & ", @extended = " & @extended)
        $EMail = $CarrierEMail
    EndIf
    
    ConsoleWrite($EMail & @LF)
    
    $EMailCC = "ABW-Clearing-D019@telefonica.com"
        
    ; neue E-Mail wird angezeigt
    $oItem.display
    $oItem.BodyFormat = $olFormatHTML
    
    ; E-Mailtext wird wird gesucht
    $sBody = $oItem.HTMLBody
    ; die Mail wird befüllt
    $oItem.HTMLBody = $HTMLKDDaten & $sBody

    _OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olTo, $EMail) ; Empfänger wird gesetzt
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error when calling function _OL_ItemRecipientAdd. @error = " & @error & ", @extended = " & @extended)
    _OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olCC, $EMailCC) ; CC wird gesetzt
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error when calling function _OL_ItemRecipientAdd. @error = " & @error & ", @extended = " & @extended)

    $oItem.send ; Email wird versendet

 

Link to comment
Share on other sites

I get the same error with the testscript

#include <OutlookEx.au3>
;~ _OL_ErrorNotify(2)
; Open the connection to Outlook
Global $oOL = _OL_Open()
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error when calling function _OL_Open(). @error = " & @error & ", @extended = " & @extended)
; Create a mail item and set some properties
Global $oItem = _OL_ItemCreate($oOL, $olMailItem, "", "", "Subject=TestMail", "BodyFormat=" & $olFormatHTML, "HTMLBody=Bodytext in <b>bold</b>.", "SentOnBehalfOfName=Doe Jane")
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error when calling function _OL_ItemCreate. @error = " & @error & ", @extended = " & @extended)
; Add a recipient and resolve it
_OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, "Doe John")
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error when calling function _OL_ItemRecipientAdd. @error = " & @error & ", @extended = " & @extended)
$oItem.Display
; Send the mail
_OL_ItemSend($oOL, $oItem)
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error when calling function _OL_ItemSend. @error = " & @error & ", @extended = " & @extended)
If @extended = -2147352567 Then _
  MsgBox(16, "OutlookEX UDF - Example Script", "You don't have permission to send the mail on behalf of the specified person!")
_OL_Close($oOL)
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error when calling function _OL_Close. @error = " & @error & ", @extended = " & @extended)

image.png.f0ecbe6b416a47b4ac36992c9f7ad652.png

 

image.png.4dd04a6e2835b1ba32c979d0e4d92b0c.png

Link to comment
Share on other sites

36 minutes ago, NolleWed said:

or do I need to enable more in my script?

No. The UDF includes the needed files automatically. 

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

38 minutes ago, NolleWed said:

You mean this way?

Yes. 

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 not at my PC at the moment.
The UDF comes with a help file. There you find the explanation for the error code. 

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

On 9/20/2022 at 12:03 PM, water said:

I’m not at my PC at the moment.
The UDF comes with a help file. There you find the explanation for the error code. 

cant find the explanation for the error code 300 in the help (if you mean OutlookEX.CHM)

Function Reference


_OL_ItemRecipientAdd

Adds one or multiple recipients or reply-recipients to an item and resolves them.

_OL_ItemRecipientAdd($oOL, $vItem, $sStoreID, $iType, $vP1[, $vP2 = ""[, $vP3 = ""[, $vP4 = ""[, $vP5 = ""[, $vP6 = ""[, $vP7 = ""[, $vP8 = ""[, $vP9 = ""[, $vP10 = ""[, $bAllowUnresolved = True]]]]]]]]]])

Parameters

$oOL Outlook object returned by a preceding call to _OL_Open()
$vItem EntryID or object of the item
$sStoreID StoreID where the item is stored. Use the keyword "Default" to use the users mailbox
$iType Integer representing the type of recipient. For details see Remarks
$vP1 Recipient to add to the item. Either a recipient object, a single recipient name or multiple recipient names separated by ; to be resolved
or a zero based one-dimensional array with unlimited number of recipients (name or object)
$vP2 [optional] recipient to add to the item. Either a recipient object or the recipient name to be resolved
$vP3 [optional] Same as $vP2
$vP4 [optional] Same as $vP2
$vP5 [optional] Same as $vP2
$vP6 [optional] Same as $vP2
$vP7 [optional] Same as $vP2
$vP8 [optional] Same as $vP2
$vP9 [optional] Same as $vP2
$vP10 [optional] Same as $vP2
$bAllowUnresolved [optional] True doesn't return an error even when unresolvable SMTP addresses have been found (default = True)

Return Value

Success: Item object
Failure: Returns 0 and sets @error:
1 - No item specified
2 - Item could not be found. EntryID might be wrong
5 - $iType is missing or not a number
3nn - Error adding recipient to the item. @extended = error code returned by the Recipients.Add method, nn = number of the invalid recipient (zero based)
4nn - Recipient name could not be resolved. @extended = error code returned by the Resolve method, nn = number of the invalid recipient (zero based)

Remarks

$vP2 to $vP10 will be ignored if $vP1 is an array of recipients
 
Valid $iType parameters:
MailItem recipient: one of the following OlMailRecipientType constants: olBCC, olCC, olOriginator, or olTo.
   Set $iType to $olReplyRecipient and the passed recipients will be set as Reply-Recipients
MeetingItem recipient: one of the following OlMeetingRecipientType constants: olOptional, olOrganizer, olRequired, or olResource.
  Set $iType to $olReplyRecipient and the passed recipients will be set as Reply-Recipients
TaskItem recipient: one of the following OlTaskRecipientType constants: olFinalStatus, or olUpdate

 

but this is from OutlookEX.au3

; #FUNCTION# ====================================================================================================================
; Name ..........: _OL_ItemRecipientAdd
; Description ...: Adds one or multiple recipients or reply-recipients to an item and resolves them.
; Syntax.........: _OL_ItemRecipientAdd($oOL, $vItem, $sStoreID, $iType, $vP1[, $vP2 = ""[, $vP3 = ""[, $vP4 = ""[, $vP5 = ""[, $vP6 = ""[, $vP7 = ""[, $vP8 = ""[, $vP9 = ""[, $vP10 = ""[, $bAllowUnresolved = True]]]]]]]]]])
; Parameters ....: $oOL              - Outlook object returned by a preceding call to _OL_Open()
;                  $vItem            - EntryID or object of the item
;                  $sStoreID         - StoreID where the item is stored. Use the keyword "Default" to use the users mailbox
;                  $iType            - Integer representing the type of recipient. For details see Remarks
;                  $vP1              - Recipient to add to the item. Either a recipient object, a single recipient name or multiple recipient names separated by ; to be resolved
;                  |or a zero based one-dimensional array with unlimited number of recipients (name or object)
;                  $vP2              - [optional] recipient to add to the item. Either a recipient object or the recipient name to be resolved
;                  $vP3              - [optional] Same as $vP2
;                  $vP4              - [optional] Same as $vP2
;                  $vP5              - [optional] Same as $vP2
;                  $vP6              - [optional] Same as $vP2
;                  $vP7              - [optional] Same as $vP2
;                  $vP8              - [optional] Same as $vP2
;                  $vP9              - [optional] Same as $vP2
;                  $vP10             - [optional] Same as $vP2
;                  $bAllowUnresolved - [optional] True doesn't return an error even when unresolvable SMTP addresses have been found (default = True)
; Return values .: Success - Item object
;                  Failure - Returns 0 and sets @error:
;                  |1 - No item specified
;                  |2 - Item could not be found. EntryID might be wrong
;                  |5 - $iType is missing or not a number
;                  |3nn - Error adding recipient to the item. @extended = error code returned by the Recipients.Add method, nn = number of the invalid recipient (zero based)
;                  |4nn - Recipient name could not be resolved. @extended = error code returned by the Resolve method, nn = number of the invalid recipient (zero based)
; Author ........: water
; Modified.......:
; Remarks .......: $vP2 to $vP10 will be ignored if $vP1 is an array of recipients
;+
;                  Valid $iType parameters:
;                  MailItem recipient: one of the following OlMailRecipientType constants: olBCC, olCC, olOriginator, or olTo.
;                  &nbsp;&nbsp; Set $iType to $olReplyRecipient and the passed recipients will be set as Reply-Recipients
;                  MeetingItem recipient: one of the following OlMeetingRecipientType constants: olOptional, olOrganizer, olRequired, or olResource.
;                  &nbsp; Set $iType to $olReplyRecipient and the passed recipients will be set as Reply-Recipients
;                  TaskItem recipient: one of the following OlTaskRecipientType constants: olFinalStatus, or olUpdate
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _OL_ItemRecipientAdd($oOL, $vItem, $sStoreID, $iType, $vP1, $vP2 = "", $vP3 = "", $vP4 = "", $vP5 = "", $vP6 = "", $vP7 = "", $vP8 = "", $vP9 = "", $vP10 = "", $bAllowUnresolved = True)
    If $bAllowUnresolved = Default Then $bAllowUnresolved = True
    Local $aRecipients[10], $oTempRecipient, $aTemp[1], $aRecipientsOut[0]
    If Not IsNumber($iType) Then Return SetError(5, 0, 0)
    If Not IsObj($vItem) Then
        If StringStripWS($vItem, BitOR($STR_STRIPLEADING, $STR_STRIPTRAILING)) = "" Then Return SetError(1, 0, 0)
        $vItem = $oOL.Session.GetItemFromID($vItem, $sStoreID)
        If @error Then Return SetError(2, @error, 0)
    EndIf
    ; Move members into an array
    If Not IsArray($vP1) Then
        $aRecipients[0] = $vP1
        $aRecipients[1] = $vP2
        $aRecipients[2] = $vP3
        $aRecipients[3] = $vP4
        $aRecipients[4] = $vP5
        $aRecipients[5] = $vP6
        $aRecipients[6] = $vP7
        $aRecipients[7] = $vP8
        $aRecipients[8] = $vP9
        $aRecipients[9] = $vP10
    Else
        $aRecipients = $vP1
    EndIf
    ; If a recipient consists of multiple recipients separated by ";" then we will split it and append each single recipient to the array
    For $i = 0 To UBound($aRecipients, 1) - 1
        ; Semicolon was found. Split the string into an array and add it at the end of the recipients array and set the current element to ""
        If $aRecipients[$i] <> "" Then
            If IsObj($aRecipients[$i]) Then
                ReDim $aTemp[1]
                $aTemp[0] = $aRecipients[$i]
            Else
                $aTemp = StringSplit($aRecipients[$i], ";", $STR_NOCOUNT)
            EndIf
            _ArrayConcatenate($aRecipientsOut, $aTemp)
        EndIf
    Next
    ; add recipients to the item
    #forceref $oTempRecipient ; To prevent the AU3Check warning : $oTempRecipient : declared, but Not used In Func.
    For $iIndex = 0 To UBound($aRecipientsOut) - 1
        If Not IsObj($aRecipientsOut[$iIndex]) And (StringStripWS($aRecipientsOut[$iIndex], BitOR($STR_STRIPLEADING, $STR_STRIPTRAILING)) = "" Or $aRecipientsOut[$iIndex] = Default) Then ContinueLoop
        If $iType = $olReplyRecipient Then
            $iType = $olTo
            $oTempRecipient = $vItem.ReplyRecipients.Add($aRecipientsOut[$iIndex])
        Else
            $oTempRecipient = $vItem.Recipients.Add($aRecipientsOut[$iIndex])
        EndIf
        If @error Then Return SetError(300 + $iIndex, @error, 0) ; <<<<<<<<<<<<<<<<<-----------------------------
        $oTempRecipient.Type = $iType
        $oTempRecipient.Resolve
        If @error Or Not $oTempRecipient.Resolved Then
            If Not (StringInStr($aRecipientsOut[$iIndex], "@")) Or Not ($bAllowUnresolved) Then
                $oTempRecipient.Delete ; Remove unresolved/recipient in error
                Return SetError(400 + $iIndex, @error, 0)
            EndIf
        EndIf
    Next
    $vItem.Save()
    Return $vItem
EndFunc   ;==>_OL_ItemRecipientAdd

 

I also try the scripts on the WIN 8 PC with the other office version and everthing works fine.

testscript

image.png.7e9cae7bd75aed033626c6f26177ee08.png

my script

image.png.ea0e773bd8af29ce478b6782afa97a55.png

 

Edited by NolleWed
Link to comment
Share on other sites

Guess which of this error codes covers @error = 300?image.thumb.png.c7007593596c4bcde32a93392ad562b8.png 

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

On 9/20/2022 at 8:46 PM, water said:

Guess which of this error codes covers @error = 300?image.thumb.png.c7007593596c4bcde32a93392ad562b8.png 

3nn - Error adding recipient to the item. @extended = error code returned by the Recipients.Add method, nn = number of the invalid recipient (zero based)

And how can I solve the problem? For the other Outlook version it works and I don´t know whats the difference and what I have to change :(

Edited by NolleWed
Link to comment
Share on other sites

Activate 

 _OL_ErrorNotify(2)

and check if you get a more detailed debug info

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

Today I tried the solutions on this website: Known issues with Microsoft Office automation. - AutoIt Wiki (autoitscript.com)

points: Windows Registry + In Outlook 2016

But I get the same error. I think it has some to do with the field "Recipient" (to, cc, bcc) and "SentOnBehalfOf". I think in Office365 (Outlook 2016 App) the script do not find this fields. Can this be the error?

_OL_ErrorNotify(2)
    $oOutlook= _OL_Open()
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error when calling function _OL_Open(). @error = " & @error & ", @extended = " & @extended)   
    ; wenn Carrier nicht in Mail-Liste, dann Mail ans PF zur Prüfung, wie bei Neli-Liste
    ; neue E-Mail wird erstellt
    if $CarrierEMail = "nicht gefunden" Then
        $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", "Subject=[AutoIT:ZU PRUEFEN] #abw# weiterversorgen #kurzfristiger Storno# " & $alleNummern & " , " & $relevanteNummer & " , " & $Kundennummer_Wert, "", "SentOnBehalfOfName=ABW-Clearing-D019@telefonica.com")
        If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error when calling function _OL_ItemCreate. @error = " & @error & ", @extended = " & @extended)
        $EMail = "ABW-Clearing-D019@telefonica.com"
    Else
        $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", "Subject=#abw# weiterversorgen #kurzfristiger Storno# " & $alleNummern & " , " & $relevanteNummer & " , " & $Kundennummer_Wert, "", "SentOnBehalfOfName=ABW-Clearing-D019@telefonica.com")
        If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error when calling function _OL_ItemCreate. @error = " & @error & ", @extended = " & @extended)
        $EMail = $CarrierEMail
    EndIf
    
    ConsoleWrite($EMail & @LF)
    
    $EMailCC = "ABW-Clearing-D019@telefonica.com"
        
    ; neue E-Mail wird angezeigt
    $oItem.display
    $oItem.BodyFormat = $olFormatHTML
    
    ; E-Mailtext wird wird gesucht
    $sBody = $oItem.HTMLBody
    ; die Mail wird befüllt
    $oItem.HTMLBody = $HTMLKDDaten & $sBody

    _OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olTo, $EMail) ; Empfänger wird gesetzt
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error when calling function _OL_ItemRecipientAdd. @error = " & @error & ", @extended = " & @extended)
    _OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olCC, $EMailCC) ; CC wird gesetzt
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error when calling function _OL_ItemRecipientAdd. @error = " & @error & ", @extended = " & @extended)

    $oItem.send ; Email wird versendet

 

image.png.31b930f5f42263f869711462f01f1d75.png

image.png.93c0c644dc617546b59cde5febb928c3.png

image.png.6c83d4699b58ba5e441a97b42618e8b0.png

 

image.png.23e37497876fa00e1130268c5857282c.png

 

I wrote an email manually with "Recipient" (to) = myself and "SentOnBehalfOf" =ABW-Clearing-D019@telefonica.com and then search for the header and HTML code. I don´t know if this helps to find the problem:

 

image.png.d8957c3f91c50169cbc4bf5735fe2642.png

Received: from DBAPR06MB6886.eurprd06.prod.outlook.com (2603:10a6:10:1a3::6)
 by AM0PR06MB5172.eurprd06.prod.outlook.com with HTTPS; Fri, 23 Sep 2022
 11:25:29 +0000
Authentication-Results: dkim=none (message not signed)
 header.d=none;dmarc=none action=none header.from=telefonica.com;
Received: from AS8PR06MB7398.eurprd06.prod.outlook.com (2603:10a6:20b:319::14)
 by DBAPR06MB6886.eurprd06.prod.outlook.com (2603:10a6:10:1a3::6) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.21; Fri, 23 Sep
 2022 11:25:28 +0000
Received: from AS8PR06MB7398.eurprd06.prod.outlook.com
 ([fe80::c069:2320:d3b2:e50f]) by AS8PR06MB7398.eurprd06.prod.outlook.com
 ([fe80::c069:2320:d3b2:e50f%5]) with mapi id 15.20.5654.020; Fri, 23 Sep 2022
 11:25:28 +0000
Content-Type: application/ms-tnef; name="winmail.dat"
Content-Transfer-Encoding: binary
From: ABW-Clearing-D019 <ABW-Clearing-D019@telefonica.com>
To: Nxxx Wxxx <nxxx.wxxx@telefonica.com>
Subject: #abw# weiterversorgen #kurzfristiger Storno# 1234 , VAID.Test ,
 S-5555
Thread-Topic: #abw# weiterversorgen #kurzfristiger Storno# 1234 , VAID.Test ,
 S-5555
Thread-Index: AdjPPwqnPlQirXWbS9azB0Spv0flww==
Date: Fri, 23 Sep 2022 11:25:28 +0000
Message-ID:
 <AS8PR06MB73980F8FF9F81DA85932268790519@AS8PR06MB7398.eurprd06.prod.outlook.com>
Accept-Language: en-US
Content-Language: de-DE
X-MS-Has-Attach:
X-MS-Exchange-Organization-SCL: -1
X-MS-TNEF-Correlator:
 <AS8PR06MB73980F8FF9F81DA85932268790519@AS8PR06MB7398.eurprd06.prod.outlook.com>
MIME-Version: 1.0
X-MS-Exchange-Organization-MessageDirectionality: Originating
X-MS-Exchange-Organization-AuthSource: AS8PR06MB7398.eurprd06.prod.outlook.com
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 04
X-MS-Exchange-Organization-Network-Message-Id:
 a80b068a-b122-4c87-04c5-08da9d565162
X-MS-PublicTrafficType: Email
X-MS-TrafficTypeDiagnostic: AS8PR06MB7398:EE_|DBAPR06MB6886:EE_
Return-Path: ABW-Clearing-D019@telefonica.com
X-MS-Exchange-Organization-ExpirationStartTime: 23 Sep 2022 11:25:28.6702
 (UTC)
X-MS-Exchange-Organization-ExpirationStartTimeReason: OriginalSubmit
X-MS-Exchange-Organization-ExpirationInterval: 1:00:00:00.0000000
X-MS-Exchange-Organization-ExpirationIntervalReason: OriginalSubmit
X-MS-Office365-Filtering-Correlation-Id: a80b068a-b122-4c87-04c5-08da9d565162
X-Microsoft-Antispam: BCL:0;
X-Forefront-Antispam-Report:
 CIP:255.255.255.255;CTRY:;LANG:de;SCL:-1;SRV:;IPV:NLI;SFV:SKI;H:AS8PR06MB7398.eurprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:;DIR:INB;
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2022 11:25:28.4160
 (UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: 9744600e-3e04-492e-baa1-25ec245c6f10
X-MS-Exchange-CrossTenant-AuthSource: AS8PR06MB7398.eurprd06.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-Network-Message-Id: a80b068a-b122-4c87-04c5-08da9d565162
X-MS-Exchange-CrossTenant-MailboxType: HOSTED
X-MS-Exchange-CrossTenant-UserPrincipalName: gOSCLeUU8n8jAmJ+AEpuMPTZH2ylYc1RhpAU+GVVcPwxSj78sbibwCFC+JkMj3/J1ckeDUR1dNcnuCsBrswI69PTqbyDYuXxqFfOHbMy7C8F/s0AfKjTtUrvajVtxmAK
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR06MB6886
X-MS-Exchange-Transport-EndToEndLatency: 00:00:00.9430412
X-MS-Exchange-Processed-By-BccFoldering: 15.20.5632.021
X-Microsoft-Antispam-Mailbox-Delivery:
    ucf:0;jmr:0;auth:0;dest:I;ENG:(910001)(944506478)(944626604)(920097)(425001)(930097);
X-Microsoft-Antispam-Message-Info:
    Ap3vIf0dW0PWJ6T3F5ehnFjYjXWIOZenEmK8Rw8fJvndnmBXB4234jO+D0plZjXmZ+EfaOkTgJ3VtzaX2hwk5eN7xMSwkM2ihhIiOBIVUIxpWJOr9F2MjgfbXtH2JdcWDkRt8zyyWCdLzwPGLPgLx2g2alcHFVEJYPOnmfHMusolnfnpg0Bt6rtN1vQh0LSyKfrh37UWoi6W5GM8MHN/xULfnhvvI3/xuBGpUFWyK5aI2b0PpEvcjasFMcDsvcGgvnpmDfiaXfCuICB2ZEFCp00CjYirRofVvWhBOMpiPk3cnOafqPbasRNgbSLgwq4MbuImXduzdG0nE2Y8Bbs6aPP0h+4l1v8KXekjuAlWpX3JhhWePrRqZ2dBVWCDYOfW6nyLNzrOzGR9cZydmXe3hhukk2GFdNfGmt0sKeEkOkBXuWag5UQz7BeuXFtdhSVvoQnaHHyp+jmC91+XrhLQ0NFDGUEwV0TMFy6OQ1/pb33MFbxG3VAT7OkxwushSRZX8C7m7q/RUh0PUrNupERgkg==

 

I'm getting really desperate 😌

Link to comment
Share on other sites

9 hours ago, NolleWed said:

That's about TNEF. This has nothing to do with your problem.


When searching the web for the 0x80004004 error code I got a few ideas:

  • Do you run the 64 bit version of Office? If yes, please run the script as 64 bit as well.
  • Can you please deactivate all Outlook addons and run your script again?
  • Can you hava a look at this site and check the "Programmatic Access Security".
  • Another post to check. The same error has already been discussed in 2019.
Edited by water

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...