Muss ich am Montag mal checken.
Beiträge von water
-
-
Welche Laus ist denn Dir über die Leber gelaufen?
Hier hat keiner was von Kaugummi klauen oder Vergewaltigung gesagt. Blas das Thema also nicht größer auf als es ist!
Und ich verwahre mich strikt dagegen, dass Du mir gesetzwidrige Dinge in den Mund legst!
Wenn Du solche Probleme mit den Aussagen eines Posters hast, dann regele das bitte per PN! -
Nach der Länge der Antwort zu schließen haben wir da einen wunden Punkt bei Dir getroffen?
Ein einfaches "Nein" hätte vermutlich genügt? -
Wow. Seien wir froh, dass Jon das damals nicht auch so gesehen hat.
-
Wenn's Fragen zur Excel UDF gibt, einfach hier oder in jedem beliebigen Thread mit "Excel" im Titel posten.
Als Autor der UDFs werde ich versuchen alle Fragen zu beantworten. -
Andere alternative:
Ich habe _OL_ItemRecipientCheck so angepasst, dass es einen Array zurückggibt, der nur die gültigen Adressen beinhaltet und direkt an _OL_ItemRecipientAddweitergegeben werden kann.
Beispiel:Spoiler anzeigen
[autoit]#include <OutlookEx.au3>
[/autoit] [autoit][/autoit] [autoit]
Global $oOL = _OL_Open()Global $aResult = _OL_ItemRecipientCheckEx($oOL, "<< Hier gültigen Empfänger eingeben >>", "", "", "", "", "", "", "", "", "", True)
[/autoit] [autoit][/autoit] [autoit]
Global $oItem = _OL_ItemCreate($oOL, $olMailItem, "*", "", "Subject=Test", "BodyFormat=" & $olFormatHTML, "HTMLBody=TestBody")
_OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, $aResult)
$oItem.Display
_OL_Close($oOL)
Exit; #FUNCTION# ====================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Name ..........: _OL_ItemRecipientCheck
; Description ...: Checks one/more recipients to be valid.
; Syntax.........: _OL_ItemRecipientCheck($oOL, $sP1[, $sP2 = ""[, $sP3 = ""[, $sP4 = ""[, $sP5 = ""[, $sP6 = ""[, $sP7 = ""[, $sP8 = ""[, $sP9 = ""[, $sP10 = ""[, $bOnlyValid = False]]]]]]]]]])
; Parameters ....: $oOL - Outlook object returned by a preceding call to _OL_Open()
; $sP1 - Name, Alias or SMTP mail address of one or multiple recipients separated by ";" ($sP2 to $sP10 are ignored if ";" is used)
; +or a zero based one-dimensional array with unlimited number of recipients
; $sP2 - Optional: Name, Alias or SMTP mail address of a single recipient (no concatenation of recipients using ";" allowed)
; $sP3 - Optional: Same as $sP2
; $sP4 - Optional: Same as $sP2
; $sP5 - Optional: Same as $sP2
; $sP6 - Optional: Same as $sP2
; $sP7 - Optional: Same as $sP2
; $sP8 - Optional: Same as $sP2
; $sP9 - Optional: Same as $sP2
; $sP10 - Optional: Same as $sP2
; $bOnlyValid - Optional: Only return the resolved recipients objects in a one-dimensional zero based array (default = False)
; Return values .: Success - two-dimensional one based array with the following information (for $bOnlyValid = False):
; |0 - Recipient derived from the list of recipients in $sP1
; |1 - True if the recipient could be resolved successfully
; |2 - Recipient object as returned by the Resolve method
; |3 - AddressEntry object
; |4 - Recipients mail address (empty for distribution lists). This can be:
; | PrimarySmtpAddress for an Exchange User
; | Email1Address for an Outlook contact
; | Empty for Exchange or Outlook distribution lists
; |5 - Display type is one of the OlDisplayType enumeration that describes the nature of the recipient
; |6 - Display name of the recipient
; Success - one-dimensional zero based array with the following information (for $bOnlyValid = True):
; |0 - Recipient object which was successfully resolved by the Resolve method. Unresolveable recipients are not aprt of the result!
; Failure - Returns "" and sets @error:
; |1 - $oOL is not an object
; |2 - $sP1 is empty
; |3 - Error creating recipient object. @extended contains the error returned by method CreateRecipient
; Author ........: water
; Modified ......:
; Remarks .......: When $bOnlyValid = True you get a one-dimensional zero based array with all invalid recipients removed.
; This array can easily be passed to _OL_ItemRecipientAdd.
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _OL_ItemRecipientCheckEx($oOL, $sP1, $sP2 = "", $sP3 = "", $sP4 = "", $sP5 = "", $sP6 = "", $sP7 = "", $sP8 = "", $sP9 = "", $sP10 = "", $bOnlyValid = False)Local $oRecipient, $asRecipients[10]
[/autoit] [autoit][/autoit] [autoit]
If Not IsObj($oOL) Then Return SetError(1, 0, "")
If StringStripWS($sP1, 3) = "" Then Return SetError(2, 0, "")
; Move recipients into an array
If Not IsArray($sP1) Then
If StringInStr($sP1, ";") > 0 Then
$asRecipients = StringSplit($sP1, ";", 2)
Else
$asRecipients[0] = $sP1
$asRecipients[1] = $sP2
$asRecipients[2] = $sP3
$asRecipients[3] = $sP4
$asRecipients[4] = $sP5
$asRecipients[5] = $sP6
$asRecipients[6] = $sP7
$asRecipients[7] = $sP8
$asRecipients[8] = $sP9
$asRecipients[9] = $sP10
EndIf
Else
$asRecipients = $sP1
EndIf
If $bOnlyValid Then
Local $asResult[UBound($asRecipients, 1)]
Local $iIndex2 = 0
Else
Local $asResult[UBound($asRecipients, 1) + 1][7] = [[UBound($asRecipients, 1), 7]]
Local $iIndex2 = 1
EndIf
For $iIndex = 0 To UBound($asRecipients, 1) - 1
If StringStripWS($asRecipients[$iIndex], 3) = "" Then ContinueLoop
If Not $bOnlyValid Then $asResult[$iIndex2][0] = $asRecipients[$iIndex]
$oRecipient = $oOL.Session.CreateRecipient($asRecipients[$iIndex])
If @error Or Not IsObj($oRecipient) Then Return SetError(3, @error, "")
$oRecipient.Resolve
If @error Or Not $oRecipient.Resolved Then
If $bOnlyValid Then ContinueLoop
$asResult[$iIndex2][1] = False
Else
If $bOnlyValid Then
$asResult[$iIndex2] = $oRecipient
Else
$asResult[$iIndex2][1] = True
$asResult[$iIndex2][2] = $oRecipient
Switch $oRecipient.AddressEntry.AddressEntryUserType
; Exchange user that belongs to the same or a different Exchange forest
Case $olExchangeUserAddressEntry, $olExchangeRemoteUserAddressEntry
$asResult[$iIndex2][3] = $oRecipient.AddressEntry.GetExchangeUser
$asResult[$iIndex2][4] = $oRecipient.AddressEntry.GetExchangeUser.PrimarySmtpAddress
; Address entry in an Outlook Contacts folder
Case $olOutlookContactAddressEntry
$asResult[$iIndex2][3] = $oRecipient.AddressEntry.GetContact
$asResult[$iIndex2][4] = $oRecipient.AddressEntry.GetContact.Email1Address
; Address entry in an Exchange Distribution list
Case $olExchangeDistributionListAddressEntry
$asResult[$iIndex2][3] = $oRecipient.AddressEntry.GetExchangeDistributionList
; Address entry in an an Outlook distribution list
Case $olOutlookDistributionListAddressEntry
$asResult[$iIndex2][3] = $oRecipient.AddressEntry
Case Else
EndSwitch
$asResult[$iIndex2][5] = $oRecipient.DisplayType
$asResult[$iIndex2][6] = $oRecipient.Name
EndIf
EndIf
$iIndex2 = $iIndex2 + 1
Next
If $bOnlyValid Then ReDim $asResult[$iIndex2]
Return $asResultEndFunc ;==>_OL_ItemRecipientCheckEx
[/autoit] -
Hier ein funktionierendes Beispiel. "John Doe" musst Du noch durch einen gültigen Namen ersetzen. Einige zeilen habe ich auskommentiert oder den für den Test nicht verwendbaren Teil nach rechts in einen Kommentar verschoben.
[autoit]#include <OutlookEx.au3>
[/autoit][autoit][/autoit][autoit]
Global $pcc = "", $Betreff = "TestBetreff", $textfeld = "TestText"
Senden()
ExitFunc Senden()
[/autoit][autoit][/autoit][autoit]
Local $data = "john doe;xyz123" ; $pto
Local $data1 = $pcc
Local $data2 = "" ; _GUICtrlEdit_GetText($fbcc)
Local $cc = StringSplit($data1, ";", 2)
Local $bcc = StringSplit($data2, ";", 2); Open the connection to Outlook
[/autoit][autoit][/autoit][autoit]
Global $oOL = _OL_Open(); Mailusertest
[/autoit][autoit][/autoit][autoit]
Global $aResult = _OL_ItemRecipientCheck($oOL, $data)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemRecipientCheck Example Script", "Error frunning _OL_ItemRecipientCheck. @error = " & @error & ", @extended = " & @extended)
_ArrayDisplay($aResult, "OutlookEX UDF: _OL_RecipientCheck Example Script", _
"", 0, "|", "Row|Recipient|Resolved?|Recipient object|AddressEntry object|Mail address|DisplayType|Name")Global $aTo[$aResult[0][0]], $j = 0
[/autoit][autoit][/autoit][autoit]
For $i = 1 To $aResult[0][0]
If $aResult[$i][1] = True Then
$aTo[$j] = $aResult[$i][2]
$j = $j + 1
Endif
Next; Create a mail item and set some properties
[/autoit][autoit][/autoit][autoit]
Global $oItem = _OL_ItemCreate($oOL, $olMailItem, "*", "", "Subject=" & $betreff, "BodyFormat=" & $olFormatHTML, "HTMLBody=" & $textfeld) ; , "SentOnBehalfOfName=Servicedesk"); Add a recipient and resolve it
[/autoit][autoit][/autoit][autoit]
_OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, $aTo)
; _OL_ItemRecipientAdd($oOL, $oItem, Default, $olcc, $cc)
; _OL_ItemRecipientAdd($oOL, $oItem, Default, $olbcc, $bcc); Send the mail
[/autoit][autoit][/autoit][autoit]
_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!")EndFunc ;==>Senden
[/autoit] -
Hier findest Du die Unterschiede zwischen den beiden Excel Versionen.
-
Mein Fehler.
RecipientAdd erwartet 1-10 Empfänger Objekte, 1-10 Empfänger Namen oder einen Array an Empfängern (Objekt oder Name). Was möchtest Du übergeben? -
Der "permission error" zeigt an, dass Du keine "permission" sprich Berechtigung hast

Der Eigentümer der Mailbox muss Dir erlauben, dass Du in seinem Namen Mails versenden darfst. -
Du musstdringend Deine Array Kenntnisse auffrischen
[autoit]
Global $sTo = ""
[/autoit]
For $i = 1 To $aResult[0][0]
If $aResult[$i][1] = True Then $sTo &= $aResult[$i][0] & ";"
Next
ConsoleWrite($sTo & @CRLF) -
In einem Loop durchs Array gehen und nur jene mit True in einem String zusammenfassen und mit ";" trennen?
-
Dieses Beispiel zeigt, wie sich eine falsche Adresse (Nummer 3) von korrekten unterscheidet:
[autoit]#include <OutlookEX.au3>
[/autoit][autoit][/autoit][autoit]Global $oOutlook = _OL_Open()
[/autoit][autoit][/autoit][autoit]
If @error Then Exit MsgBox(16, "OutlookEX UDF - _OL_RecipientCheck Example Script", "Error running _OL_Open. @error = " & @error & ", @extended = " & @extended)Global $aResult = _OL_ItemRecipientCheck($oOutlook, $oOutlook.GetNameSpace("MAPI").CurrentUser.Name & ";[email='test.user@google.com'][/email];Wrong address")
[/autoit][autoit][/autoit][autoit]
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemRecipientCheck Example Script", "Error frunning _OL_ItemRecipientCheck. @error = " & @error & ", @extended = " & @extended)
_ArrayDisplay($aResult, "OutlookEX UDF: _OL_RecipientCheck Example Script", _
"", 0, "|", "Row|Recipient|Resolved?|Recipient object|AddressEntry object|Mail address|DisplayType|Name")_OL_Close($oOutlook)
[/autoit] -
Die Funktion erwartet die Recipients als String getrennt durch ";":
[autoit]
"Name, Alias or SMTP mail address of one or multiple recipients separated by ;"
Nimm also$sToCheck = _ArrayToString($To, ";")
[/autoit] -
Kein Problem. Danke für die Rückmeldung!
-
Dafür gibt es die Funktion _OL_RecipientCheck. Damit lässt sich prüfen, ob der/die Empfänger gültig ist.
-
Also Problem gelöst?
-
-
"\\Wartung\Posteingang Standort" sieht gut aus.
-
Versuch's mal mit folgendem Filter mit _AD_GetObjectsInOU.
"(&(objectCategory=person)(objectClass=user)(primaryGroupID=513))"