Das ist für mich auch schwierig zu beurteilen.
Die Arbeit hast du und wie viel es bringt kann ich dir auch nicht sagen.
Eventuell können andere dir da mehr Rückmeldung geben.
Ob das allerdings wer liest hier ist auch fraglich.
Das ist für mich auch schwierig zu beurteilen.
Die Arbeit hast du und wie viel es bringt kann ich dir auch nicht sagen.
Eventuell können andere dir da mehr Rückmeldung geben.
Ob das allerdings wer liest hier ist auch fraglich.
Ich halte davon viel.
Und alle die deine UDF verwenden und aktuell halten, werden es dir danken, wenn sie nichts an ihren Programmen umändern müssen.
OK ich habe es herausbekommen.
Man muss natürlich die Attachments ansprechen.
Hier also der funktionierende Code ohne extra die Eigenschaften der Attachments auszulesen.
#include <OutlookEx.au3>
$oOutlook = _OL_Open()
_OL_ErrorNotify(2)
; *****************************************************************************
; Example 4
; Create a html mail plus two attachments (plus one inline picture = attachment)
; but don't send it
; Inline picture using Content-ID
; http://stackoverflow.com/questions/9158706/how-to-embed-an-image-on-an-outlook-2007-vsto
; *****************************************************************************
; Create the item without setting the body. We first need to add the picture before we can refer to in by the HTML body.
$oItem = _OL_ItemCreate($oOutlook, $olMailItem, "*", "", "Subject=TestMail", "BodyFormat=" & $olFormatHTML)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error creating a mail in folder 'Outlook-UDF-Test\TargetFolder\Mail'. @error = " & @error & ", @extended = " & @extended)
; Add all attachments
$oItem = _OL_ItemAttachmentAdd($oOutlook, $oItem, Default, @ScriptDir & "\The_Outlook.jpg, 1, 0")
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error adding an attachment to a mail in folder 'Outlook-UDF-Test\TargetFolder\Mail'. @error = " & @error & ", @extended = " & @extended)
$oItem.Attachments(1).PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E", "The_Outlook.jpg")
$oItem = _OL_ItemAttachmentAdd($oOutlook, $oItem, Default, @ScriptDir & "\Outlook.png, 1, 0")
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error adding an attachment to a mail in folder 'Outlook-UDF-Test\TargetFolder\Mail'. @error = " & @error & ", @extended = " & @extended)
$oItem.Attachments(2).PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E", "Outlook.png")
; Modify the item to add HTML that refers to the picture
$oItem = _OL_ItemModify($oOutlook, $oItem, Default, "HTMLBody=Bodytext in <b>bold</b><img src='cid:The_Outlook.jpg'>Embedded image.Bodytext in <b>bold</b><img src='cid:Outlook.png'>Embedded image.")
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error modifying the item in folder 'Outlook-UDF-Test\TargetFolder\Mail'. @error = " & @error & ", @extended = " & @extended)
_OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olBCC, "test.test@test.com")
_OL_ItemSend($oOutlook, $oItem, Default)
If @error <> 0 Then
Exit
Else
MsgBox(64, "OutlookEX UDF: _OL_ItemCreate Example Script", "Mail with inline picture created.")
Endif
Alles anzeigen
Hier der Code der soweit das macht, was ich erreichen will.
Die Bilder Outlook.png und The_Outlook.jpg müssen dazu im Scriptordner vorhanden sein.
Beide sind in der OutlookUDF von Water enthalten.
#include <OutlookEX.au3>
Global $oOutlook = _OL_Open()
_OL_ErrorNotify(2)
Global $iCount
Global $ContentID = "@" & Hex(@YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC, 12)
Global $oMail = _OL_ItemCreate($oOutlook, $olMailItem, "*", "", "Subject=TestMail", "BodyFormat=" & $olFormatHTML, _
'HTMLBody=This is a picture.<img src="cid:Outlook.png' & $ContentID & '">This is more text.<img src="cid:The_Outlook.jpg' & $ContentID & '">')
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error creating a mail item. @error = " & @error & ", @extended = " & @extended)
_AttachmentAdd(@ScriptDir & "\Outlook.png")
_AttachmentAdd(@ScriptDir & "\The_Outlook.jpg")
_OL_ItemRecipientAdd($oOutlook, $oMail, Default, $olBCC, "test.test@test.com")
_OL_ItemSend($oOutlook, $oMail, Default)
_OL_Close($oOutlook)
Func _AttachmentAdd($sPicturePath)
Local $PicName = StringTrimLeft($sPicturePath, StringInStr($sPicturePath, "\", 0 , -1)); & "@"
$oItem = _OL_ItemAttachmentAdd($oOutlook, $oMail, Default, $sPicturePath & ", 1, 0")
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error adding an attachment to the mail item. @error = " & @error & ", @extended = " & @extended)
$aOutlookinfo = _OL_ItemAttachmentGet($oOutlook, $oMail, Default)
$iCount += 1
$aOutlookinfo[$iCount][0].PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E", $PicName & $ContentID)
EndFunc ;==>_AttachmentAdd
Alles anzeigen
Hallo Water!
Mit deinem Code erhalte ich:
Was ich auch nicht ganz verstehe ist warum deine Funktion _OL_ItemAttachmentAdd nicht das Attachmentobject zurück gibt?
Laut dem Beschreibungstext der Funktion sollte das doch sein?
Damit sollte man doch auch PropertyAccessor setzen können?
Das Beispiel unten funktioniert aber nicht.
ZitatAlles anzeigen; #FUNCTION# ====================================================================================================================
; Name ..........: _OL_ItemAttachmentAdd
; Description ...: Adds one or more attachments to an item.
; Syntax.........: _OL_ItemAttachmentAdd($oOL, $vItem, $sStoreID, $vP1[, $vP2 = ""[, $vP3 = ""[, $vP4 = ""[, $vP5 = ""[, $vP6 = ""[, $vP7 = ""[, $vP8 = ""[, $vP9 = ""[, $vP10 = ""[, $sDelimiter = ","]]]]]]]]]])
; Parameters ....: $oOL - Outlook object returned by a preceding call to _OL_Open()
; $vItem - EntryID or object of the item
; $sStoreID - StoreID where the EntryID is stored. Use the keyword "Default" to use the users mailbox
; $vP1 - The source of the attachment. This can be a file (represented by the full file system path (drive letter or UNC path) with a file name) or an
; +Outlook item (EntryId or object) that constitutes the attachment
; +or a zero based one-dimensional array with unlimited number of attachments.
; |Every attachment parameter can consist of up to 4 sub-parameters separated by commas or parameter $sDelimiter:
; | 1 - Source: The source of the attachment as described above
; | 2 - (Optional) Type: The type of the attachment. Can be one of the OlAttachmentType constants (default = $olByValue)
; | 3 - (Optional) Position: For RTF format. Position where the attachment should be placed within the body text (default = Beginning of the item)
; | 4 - (Optional) DisplayName: For RTF format and Type = $olByValue. Name is displayed in an Inspector object or when viewing the properties of the attachment
; $vP2 - [optional] Same as $vP1 but no array is allowed
; $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
; $sDelimiter - [optional] Delimiter to separate the sub-parameters of the attachment parameters $vP1 - $vP10 (default = ",")
; Return values .: Success - Item object
; Failure - Returns 0 and sets @error:
; |1 - No Outlook item specified
; |2 - Item could not be found. EntryID might be wrong
; |3 - Error adding attachment to the item list. @extended = number of the invalid attachment (zero based)
; |4 - Attachment could not be found. @extended = number of the invalid attachment (zero based)
; Author ........: water, seadoggie01
; Modified.......:
; Remarks .......: $vP2 to $vP10 will be ignored if $vP1 is an array of attachments.
; For more details about sub-parameters 2-4 please check MSDN for the Attachments.Add method
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Ca. so:
$oItem = _OL_ItemAttachmentAdd($oOutlook, $oMail, Default, $sPicturePath & ", 1, 0")
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error adding an attachment to the mail item. @error = " & @error & ", @extended = " & @extended)
$oItem.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E", $ContentID)
Ich hab jetzt wieder die deine _OL_ItemAttachmentGet missbraucht.
Kannst du mir da einen "sauberen" Weg zeigen, wie man "http://schemas.microsoft.com/mapi/proptag/0x3712001E" setzt
Wenn man "http://schemas.microsoft.com/mapi/proptag/0x3712001E" setzt dann schaut das sehr gut aus mit Outlook Thunderbird und K-9
#include <OutlookEX.au3>
#include <debug.au3>
_OL_ErrorNotify(2)
$oOutlook = _OL_Open()
$oMail = _OL_ItemCreate($oOutlook, $olMailItem, "*", "", "Subject=TestMail", "BodyFormat=" & $olFormatHTML, _
'HTMLBody=This is a picture.<img src="cid:test">This is more text.')
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error creating a mail item. @error = " & @error & ", @extended = " & @extended)
$oItem = _OL_ItemAttachmentAdd($oOutlook, $oMail, Default, @ScriptDir & "\The_Outlook.JPG, 1, 0")
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error adding an attachment to the mail item. @error = " & @error & ", @extended = " & @extended)
;_OL_ItemModify($oOutlook, $oItem, Default, "http://schemas.microsoft.com/mapi/proptag/0x3712001E=test")
$aOutlookinfo = _OL_ItemAttachmentGet2($oOutlook, $oMail, Default)
_DebugArrayDisplay($aOutlookinfo, "Outlookinfo", "", 0, Default, "Object to the attachment|DisplayName|FileName|PathName|Position|Size|Type|Index|Class|BlockLevel|0x3712001E|0x3713001E|0x37050003|0x37140003")
$asplit = StringSplit("Object to the attachment|DisplayName|FileName|PathName|Position|Size|Type|Index|Class|BlockLevel|0x3712001E|0x3713001E|0x37050003|0x37140003", "|")
For $i = 1 To UBound($aOutlookinfo, 2) - 1
ConsoleWrite($asplit[$i + 1] & @TAB & " --> " & @TAB & $aOutlookinfo[1][$i] & @CRLF)
Next
_OL_ItemRecipientAdd($oOutlook, $oMail, Default, $olBCC, "test@test.com")
;_OL_ItemSend($oOutlook, $oMail, Default)
;$oMail.Display
_OL_Close($oOutlook)
; #FUNCTION# ====================================================================================================================
; Name ..........: _OL_ItemAttachmentGet
; Description ...: Returns a list of attachments of an item.
; Syntax.........: _OL_ItemAttachmentGet($oOL, $vItem[, $sStoreID = Default])
; Parameters ....: $oOL - Outlook object returned by a preceding call to _OL_Open()
; $vItem - EntryID or object of the item
; $sStoreID - [optional] StoreID where the EntryID is stored (default = users mailbox)
; Return values .: Success - two-dimensional one based array with the following information:
; |0 - Object to the attachment
; |1 - DisplayName: String representing the name, which does not need to be the actual file name, displayed below the icon representing the embedded attachment
; |2 - FileName: String representing the file name of the attachment
; |3 - PathName: String representing the full path to the linked attached file
; |4 - Position: Integer indicating the position of the attachment within the body of the item
; |5 - Size: Integer indicating the size (in bytes) of the attachment
; |6 - Type: OlAttachmentType constant indicating the type of the specified object
; Failure - Returns 0 and sets @error:
; |1 - No Outlook item specified
; |2 - Item could not be found. EntryID might be wrong
; |3 - Item has no attachments
; Author ........: water
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _OL_ItemAttachmentGet2($oOL, $vItem, $sStoreID = Default)
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
If $vItem.Attachments.Count = 0 Then Return SetError(3, 0, 0)
Local $aAttachments[$vItem.Attachments.Count + 1][14] = [[$vItem.Attachments.Count, 14]]
Local $iIndex = 1
For $oAttachment In $vItem.Attachments
$aAttachments[$iIndex][0] = $oAttachment
$aAttachments[$iIndex][1] = $oAttachment.DisplayName
$aAttachments[$iIndex][2] = $oAttachment.FileName
$aAttachments[$iIndex][3] = $oAttachment.PathName
$aAttachments[$iIndex][4] = $oAttachment.Position
$aAttachments[$iIndex][5] = $oAttachment.Size
$aAttachments[$iIndex][6] = $oAttachment.Type
$aAttachments[$iIndex][7] = $oAttachment.Index
$aAttachments[$iIndex][8] = $oAttachment.Class
$aAttachments[$iIndex][9] = $oAttachment.BlockLevel
$oAttachment.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E", "test")
$aAttachments[$iIndex][10] = $oAttachment.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E")
$aAttachments[$iIndex][11] = $oAttachment.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3713001E")
$aAttachments[$iIndex][12] = $oAttachment.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x37050003")
$aAttachments[$iIndex][13] = $oAttachment.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x37140003")
$iIndex += 1
Next
Return $aAttachments
EndFunc ;==>_OL_ItemAttachmentGet2
Alles anzeigen
Hi!
Gut dann war ich nicht ganz auf dem Holzweg.
Also wenn man es auf das Outlook.jpg Beispiel anwendet, erhält man.
ZitatContent ID :
Content Location: The_Outlook.jpg
Method : 1
Flags : 0
Danke für deine Bemühung
Wie kann ich jetzt diese Eigenschaften ändern?
Mit _OL_ItemModify? Und wenn ja wie
Danke für deinen Beitrag. Das habe ich auch schon gemacht. An der HTML liegt es nicht.
Bei dir klinkt das immer so einfach
Wie mach ich das?
Ich habe versucht deine _OL_ItemAttachmentGet Funktion zu erweitern.
Aber aus Mangel an Wissen funktioniert das nicht.
; #FUNCTION# ====================================================================================================================
; Name ..........: _OL_ItemAttachmentGet
; Description ...: Returns a list of attachments of an item.
; Syntax.........: _OL_ItemAttachmentGet($oOL, $vItem[, $sStoreID = Default])
; Parameters ....: $oOL - Outlook object returned by a preceding call to _OL_Open()
; $vItem - EntryID or object of the item
; $sStoreID - [optional] StoreID where the EntryID is stored (default = users mailbox)
; Return values .: Success - two-dimensional one based array with the following information:
; |0 - Object to the attachment
; |1 - DisplayName: String representing the name, which does not need to be the actual file name, displayed below the icon representing the embedded attachment
; |2 - FileName: String representing the file name of the attachment
; |3 - PathName: String representing the full path to the linked attached file
; |4 - Position: Integer indicating the position of the attachment within the body of the item
; |5 - Size: Integer indicating the size (in bytes) of the attachment
; |6 - Type: OlAttachmentType constant indicating the type of the specified object
; Failure - Returns 0 and sets @error:
; |1 - No Outlook item specified
; |2 - Item could not be found. EntryID might be wrong
; |3 - Item has no attachments
; Author ........: water
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _OL_ItemAttachmentGet($oOL, $vItem, $sStoreID = Default)
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
If $vItem.Attachments.Count = 0 Then Return SetError(3, 0, 0)
Local $aAttachments[$vItem.Attachments.Count + 1][11] = [[$vItem.Attachments.Count, 11]]
Local $iIndex = 1
For $oAttachment In $vItem.Attachments
$aAttachments[$iIndex][0] = $oAttachment
$aAttachments[$iIndex][1] = $oAttachment.DisplayName
$aAttachments[$iIndex][2] = $oAttachment.FileName
$aAttachments[$iIndex][3] = $oAttachment.PathName
$aAttachments[$iIndex][4] = $oAttachment.Position
$aAttachments[$iIndex][5] = $oAttachment.Size
$aAttachments[$iIndex][6] = $oAttachment.Type
$aAttachments[$iIndex][7] = $oAttachment.Index
$aAttachments[$iIndex][8] = $oAttachment.Class
$aAttachments[$iIndex][9] = $oAttachment.BlockLevel
$aAttachments[$iIndex][10] = $oAttachment.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E")
$iIndex += 1
Next
Return $aAttachments
EndFunc ;==>_OL_ItemAttachmentGet
Alles anzeigen
@GM
Ja das habe ich schon gemacht.
Ich brauch so was denke ich nur habe ich keine Ahnung wie ich das umsetzt:
Code//CONTENT-ID const string schemaPrAttachContentId = @"http://schemas.microsoft.com/mapi/proptag/0x3712001E"; var contentId = Guid.NewGuid().ToString(); mail.Attachments.Add(imagePath, OlAttachmentType.olEmbeddeditem, mail.HTMLBody.Length, Type.Missing); mail.Attachments[mail.Attachments.Count].PropertyAccessor.SetProperty(schemaPrAttachContentId, contentId);
Schnuffel #10
Ja stimmt schon. Hierfür braucht man halt einen Webserver. Diesen zu betreiben ist mir der Aufwand nicht wert.
Mein Testcode ist so genau dein Beispielscript.
Ich vermute, dass man dem Attachment einen Parameter mitgeben muss damit es nicht als normales Attachment wahrgenommen wird.
Hättest du eine Ahnung wie ich das hier umsetzen kann mit deiner UDF
Schnuffel Meinst du direkt in den HMTL Code? Wenn ja das habe ich auch schon probiert. Outlook stellt das auch "sauber" dar aber K-9 am Smartphone nicht.
water Meinst du https://web.archive.org/web/20…de.com/d/code/htmlimg.htm
Leider komm ich damit auch nicht zurecht.
To attach multiple embedded images to a message, set the value of the &H3712001E field
Was ist das für ein Feld? wie könnte ich es befüllen?
BugFix Nein der Mailclient stellt HTML schon dar
Hallo!
Ich würde gerne Emails per Outlook versenden, die ein Bild im Text enthalten. (HTML Body)
Das ist Erstellen und Versenden funktioniert auch wunderbar dank Waters OutlookEX UDF.
Die erstellten Mails enthalten auch das Bild und in Outlook werden sie auch richtig dargestellt, nur mit der Büroklammer als Schönheitsfehler.
In anderen Mailclients wird das Bild aber überhaupt nicht in der Email dargestellt sondern "nur" als Anhang.
Water wurde dazu schon vor mehr als 10 Jahren im Englischen Forum tätig.
Dort hatte er auf die Webseite http://www.outlookcode.com verwiesen. Beitrag aus dem englischen Forum
Diese ist leider nicht mehr verfügbar und somit konnte ich nicht nachsehen.
Hat jemand von euch eine Idee wie ich das Bild als Anhang einbinde damit es im Text sichtbar ist und nicht als Anhang selber zum Downloaden angeboten wird.
Hier mein Testcode:
#include <OutlookEx.au3>
$oOutlook = _OL_Open()
$oMail = _OL_ItemCreate($oOutlook, $olMailItem, "*", "", "Subject=TestMail", "BodyFormat=" & $olFormatHTML, _
'HTMLBody=This is a picture.<img src="cid:The_Outlook.jpg">This is more text.')
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error creating a mail item. @error = " & @error & ", @extended = " & @extended)
$oItem = _OL_ItemAttachmentAdd($oOutlook, $oMail, Default, @ScriptDir & "\The_Outlook.JPG")
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error adding an attachment to the mail item. @error = " & @error & ", @extended = " & @extended)
_OL_ItemRecipientAdd($oOutlook, $oMail, Default, $olBCC, "test.test@test.com")
_OL_ItemSend($oOutlook, $oMail, Default)
;$oMail.Display
_OL_Close($oOutlook)
Alles anzeigen
Bei dem Hinweis von BugFix ist aber wichtig das Kleingedruckte in der Hilfe zu lesen.
Und ich bin heil froh, dass es so ist, sonst wäre das eine recht große Sicherheitslücke meiner Meinung nach.
Zitataus der Hilfe:
Running Scripts
Important Notes
However, the executable must have been compiled with the #pragma compile(AutoItExecuteAllowed, True) directive as the default setting does not permit use of the /AutoItExecuteScript or /AutoItExecuteLine parameters. Moreover, since the interpreter stub searches for any required standard #include files in its current folder, UDF functions and various constants may not be available as those files are normally only found in the full AutoIt install. It is therefore recommended that any scripts intended to be run in this manner are compiled to the .a3x format rather then being left as plain .au3 text files
Correct usage of single and double quotation marks is important when using the command line - even for double single quotation marks.
Hi!
Hier Code mit dem ich ein ähnliches Projekt realisiert habe.
#include <String.au3>
Local $sRequest, $sCookies
;Local $ip = "192.168.0.1"
TCPStartup()
Local $ip = TCPNameToIP("neverssl.com")
TCPShutdown()
$sRequest = _TCPRequest($ip, "neverssl.com")
ConsoleWrite("-------------------------------------------" & @CRLF & $sRequest & @CRLF)
$sCookies = _GetCookies($sRequest)
ConsoleWrite("-------------------------------------------" & @CRLF & $sCookies & @CRLF)
Func _GetCookies($sQuellcode)
Local $sCookies, $i, $aCookies
$sCookies = ''
$aCookies = _StringBetween($sQuellcode, 'Set-Cookie: ', @CRLF, 1)
For $i = 0 To UBound($aCookies) - 1
$sCookies &= $aCookies[$i] & ';'
Next
Return $sCookies
EndFunc ;==>_GetCookies
Func _TCPRequest($sIp, $sHost, $sSeite = "", $sPost = '', $sCookies = '', $sReferer = '')
Local $sPacket, $iSocket, $iTimer, $sRecv
If $sPost = '' Then
$sPacket = 'GET /' & $sSeite & ' HTTP/1.1' & @CRLF
Else
$sPacket = 'POST /' & $sSeite & ' HTTP/1.1' & @CRLF
EndIf
$sPacket &= 'Host: ' & $sHost & @CRLF & _
'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0' & @CRLF & _
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' & @CRLF & _
'Accept-Language: de,en-US;q=0.7,en;q=0.3' & @CRLF & _
'Connection: keep-alive' & @CRLF
;'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7' & @CRLF & _
;'Keep-Alive: 115' & @CRLF & _
If $sReferer <> '' Then
$sPacket &= 'Referer: ' & $sReferer & @CRLF
EndIf
If $sCookies <> '' Then
$sPacket &= 'Cookie: ' & "testcookie; " & $sCookies & @CRLF
EndIf
If $sPost <> '' Then
$sPacket &= 'Content-Type: application/x-www-form-urlencoded' & @CRLF
$sPacket &= 'Content-Length: ' & StringLen($sPost) & @CRLF
EndIf
$sPacket &= @CRLF
If $sPost <> '' Then
$sPacket &= $sPost
EndIf
;ConsoleWrite(@CR & $sPacket & @CR)
TCPStartup()
If @error Then Return SetError(1, 0, "")
$iSocket = TCPConnect($sIp, 80)
If @error Then Return SetError(2, 0, "")
TCPSend($iSocket, $sPacket)
If @error Then Return SetError(3, 0, "")
Local $bytes = 0, $parse_start, $seconds, $timer_start = TimerInit()
While 1
;_checkMessages() ;My nMsg routine
$sRecv &= TCPRecv($iSocket, 4096)
;If @error = -1 Then ExitLoop ;Just to be thorough
$parse_start = StringInStr($sRecv, "Content-Length") + 15
If $parse_start > 15 Then $bytes = Int(StringStripWS(StringStripCR(StringMid($sRecv, $parse_start, StringInStr($sRecv, @CRLF, 0, 1, $parse_start) - $parse_start)), 8))
;This is what really makes the difference. Were waiting for all the data to come in
If $bytes > 0 And StringLen($sRecv) >= $bytes Then ExitLoop
If TimerDiff($timer_start) > 1000 + ($seconds * 1000) Then
$seconds += 1
If $seconds = 5 Then ExitLoop ;Last resort
EndIf
WEnd
TCPCloseSocket($iSocket)
TCPShutdown()
Return BinaryToString($sRecv)
EndFunc ;==>_TCPRequest
Alles anzeigen
Ich denke du solltest aber mit der Funktion zurecht kommen.
Geh den Loginvorgang mit dem developer Mode durch und erstelle die Requests genau so.
Auszug aus der Seite die du verlinkt hast (
In Chrome go to the View menu - Developer - Developer Tools and the Dev panel should open to the right hand side. Under the Network Tab then Headers Tab you will see the Request Headers Section, your Authorization token can be found here. Copy this for use later
)
Eventuell passt du den Header in der Funktion noch an.
Sollte aber nicht unbedingt notwendig sein.
Mir ist aufgefallen, dass man oft nicht alle Requests braucht, soll heissen, Seite aufrufen erster Request meist erhält man dann das Cookie das man braucht um dann direkt den Login Request abzusetzen.
Und alle Requests dazwischen sind nicht nötig.
Du weißt aber schon, dass das nicht zwingend notwendig ist?
Solange es mit einem gültigen Zeitstempel signiert wurde.
Mit Powershell geht es auch
Get-AuthenticodeSignature C:\Windows\explorer.exe | Format-List
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Change2CUI=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Debug.au3>
Local $sFile = "C:\Windows\explorer.exe"
Local $sCommandline = 'powershell "& Get-AuthenticodeSignature ''' & $sFile & ''' | Format-List"'
Local $iRun = Run($sCommandline, @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
ProcessWaitClose($iRun)
Local $sOutput = StdoutRead($iRun)
;ConsoleWrite("$sOutput " & $sOutput & @CRLF)
Local $aArray = StringRegExp($sOutput, "(\b\d{2}.\d{2}.\d{4} \d{2}:\d{2}:\d{2})", 3)
_DebugArrayDisplay($aArray)
Alles anzeigen
Array0 Zertifikat Beginn
Array1 Zertifikat Ende
Array2 Timestamp Beginn
Array3 Timestamp Ende
Ich nehme mal an ihr signiert eure Files mit SignTool.exe von Microsoft!?
Damit kann man das auch überprüfen.
SignTool verify /?
C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64>SignTool verify /v "C:\Windows\explorer.exe"
Verifying: C:\Windows\explorer.exe
Signature Index: 0 (Primary Signature)
Hash of file (sha256): 7177E59926D1B65B386989764E121E9D37C41BCFF9799E3F1D938D5DE12AAA8B
Signing Certificate Chain:
Issued to: Microsoft Root Certificate Authority 2010
Issued by: Microsoft Root Certificate Authority 2010
Expires: Sun Jun 24 00:04:01 2035
SHA1 hash: 3B1EFD3A66EA28B16697394703A72CA340A05BD5
Issued to: Microsoft Windows Production PCA 2011
Issued by: Microsoft Root Certificate Authority 2010
Expires: Mon Oct 19 20:51:42 2026
SHA1 hash: 580A6F4CC4E4B669B9EBDC1B2B3E087B80D0678D
Issued to: Microsoft Windows
Issued by: Microsoft Windows Production PCA 2011
Expires: Thu Sep 01 20:23:41 2022
SHA1 hash: FE51E838A087BB561BBB2DD9BA20143384A03B3F
The signature is timestamped: Wed Mar 02 13:44:34 2022
Timestamp Verified by:
Issued to: Microsoft Root Certificate Authority 2010
Issued by: Microsoft Root Certificate Authority 2010
Expires: Sun Jun 24 00:04:01 2035
SHA1 hash: 3B1EFD3A66EA28B16697394703A72CA340A05BD5
Issued to: Microsoft Time-Stamp PCA 2010
Issued by: Microsoft Root Certificate Authority 2010
Expires: Mon Sep 30 20:32:25 2030
SHA1 hash: 36056A5662DCADECF82CC14C8B80EC5E0BCC59A6
Issued to: Microsoft Time-Stamp Service
Issued by: Microsoft Time-Stamp PCA 2010
Expires: Tue Feb 28 21:05:23 2023
SHA1 hash: 1306B88D68DA71B39853EFBDE72749EE14828B98
File has page hashes.
Successfully verified: C:\Windows\explorer.exe
Number of files successfully Verified: 1
Number of warnings: 0
Number of errors: 0
Alles anzeigen
Es kann oft so einfach sein.
Man muss nur genau lesen
Falls jemand auch das Problem hat, den Zeitpunkt, wann ein Registry Key das letztemal verändert wurde, remote, auszulesen.
Hier ein Beispiel:
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Change2CUI=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <APIRegConstants.au3>
#include <Date.au3>
;#include <Debug.au3>
#include <WinAPIError.au3>
#include <WinAPILocale.au3>
#include <WinAPIReg.au3>
;_DebugSetup(Default, True)
Local $sRegkey = 'SYSTEM\CurrentControlSet\Enum\DISPLAY'
If $cmdline[0] = 0 Then Exit
If $cmdline[0] = 2 Then
$sRegkey = $cmdline[2]
EndIf
Local $hKey = _WinAPI_RegConnectRegistry("\\" & $cmdline[1], $HKEY_LOCAL_MACHINE)
If @error Then
ConsoleWrite("! _WinAPI_RegConnectRegistry @error =" & @error & @CRLF & @TAB & _WinAPI_GetErrorMessage(@extended) & @CRLF)
; _DebugReport("! RegOpenKey @error =" & @error & @CRLF & @TAB &_WinAPI_GetErrorMessage(@extended) & @CRLF)
Exit
EndIf
Local $hKey2 = _WinAPI_RegOpenKey($hKey, $sRegkey, $KEY_QUERY_VALUE)
If @error Then
ConsoleWrite("! _WinAPI_RegOpenKey @error =" & @error & @CRLF & @TAB & _WinAPI_GetErrorMessage(@extended) & @CRLF)
; _DebugReport("! RegOpenKey @error =" & @error & @CRLF & @TAB &_WinAPI_GetErrorMessage(@extended) & @CRLF)
Exit
EndIf
Local $tFT = _WinAPI_RegQueryLastWriteTime($hKey2)
$tFT = _Date_Time_FileTimeToLocalFileTime($tFT)
Local $tST = _Date_Time_FileTimeToSystemTime($tFT)
_WinAPI_RegCloseKey($hKey2)
_WinAPI_RegCloseKey($hKey)
;_DebugReport('! Last modified at: ' & _WinAPI_GetDateFormat(0, $tST) & ' ' & _WinAPI_GetTimeFormat(0, $tST) & @CRLF)
ConsoleWrite(_WinAPI_GetDateFormat(0, $tST) & ' ' & _WinAPI_GetTimeFormat(0, $tST) & @CRLF)
Alles anzeigen
Ich habe da ein Script gefunden für Powershell:
Anscheinend funktioniert das aber Remote auch nicht. (siehe Post dort)
Ich habe es nicht mal lokal zum funktionieren gebracht.
Ist jemand von euch fähig so etwas in Autoit umzusetzen?
Wie geht man da vor?
Es scheinen Dll Aufrufe zu sein. (advapi32.dll)
function Get-RegKeyLastWriteTime {
<#
.SYNOPSIS
Retrieves the last write time of the supplied registry key
.DESCRIPTION
The Registry data that a hive stores in containers are called cells. A cell
can hold a key, a value, a security descriptor, a list of subkeys, or a
list of key values.
Get-RegKeyLastWriteTime retrieves the LastWriteTime through a pointer to the
FILETIME structure that receives the time at which the enumerated subkey was
last written. Values do not contain a LastWriteTime property, but changes to
child values update the parent keys lpftLastWriteTime.
The LastWriteTime is updated when a key is created, modified, accessed, or
deleted.
.PARAMETER ComputerName
Computer name to query
.PARAMETER Key
Root Key to query
HKCR - Symbolic link to HKEY_LOCAL_MACHINE \SOFTWARE \Classes.
HKCU - Symbolic link to a key under HKEY_USERS representing a user's profile
hive.
HKLM - Placeholder with no corresponding physical hive. This key contains
other keys that are hives.
HKU - Placeholder that contains the user-profile hives of logged-on
accounts.
HKCC - Symbolic link to the key of the current hardware profile
.PARAMETER SubKey
Registry Key to query
.EXAMPLE
Get-RegKeyLastWriteTime -ComputerName testwks -Key HKLM -SubKey Software
.EXAMPLE
Get-RegKeyLastWriteTime -ComputerName testwks1,testwks2 -SubKey Software
.EXAMPLE
Get-RegKeyLastWriteTime -SubKey Software\Microsoft
.EXAMPLE
"testwks1","testwks2" | Get-RegKeyLastWriteTime -SubKey Software\Microsoft `
\Windows\CurrentVersion
.NOTES
NAME: Get-RegKeyLastWriteTime
AUTHOR: Shaun Hess
VERSION: 1.0
LASTEDIT: 01JUL2011
LICENSE: Creative Commons Attribution 3.0 Unported License
(http://creativecommons.org/licenses/by/3.0/)
.LINK
http://www.shaunhess.com
#>
[CmdletBinding()]
param(
[parameter(
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)]
[Alias("CN","__SERVER","Computer","CNAME")]
[string[]]$ComputerName=$env:ComputerName,
[string]$Key = "HKLM",
[string]$SubKey
)
BEGIN {
switch ($Key) {
"HKCR" { $searchKey = 0x80000000} #HK Classes Root
"HKCU" { $searchKey = 0x80000001} #HK Current User
"HKLM" { $searchKey = 0x80000002} #HK Local Machine
"HKU" { $searchKey = 0x80000003} #HK Users
"HKCC" { $searchKey = 0x80000005} #HK Current Config
default {
"Invalid Key. Use one of the following options:
HKCR, HKCU, HKLM, HKU, HKCC"}
}
$KEYQUERYVALUE = 0x1
$KEYREAD = 0x19
$KEYALLACCESS = 0x3F
}
PROCESS {
foreach($computer in $ComputerName) {
$sig0 = @'
[DllImport("advapi32.dll", SetLastError = true)]
public static extern int RegConnectRegistry(
string lpMachineName,
int hkey,
ref int phkResult);
'@
$type0 = Add-Type -MemberDefinition $sig0 -Name Win32Utils ` -Namespace
RegConnectRegistry -Using System.Text -PassThru
$sig1 = @'
[DllImport("advapi32.dll", CharSet = CharSet.Auto)]
public static extern int RegOpenKeyEx(
int hKey,
string subKey,
int ulOptions,
int samDesired,
out int hkResult);
'@
$type1 = Add-Type -MemberDefinition $sig1 -Name Win32Utils `
-Namespace RegOpenKeyEx -Using System.Text -PassThru
$sig2 = @'
[DllImport("advapi32.dll", EntryPoint = "RegEnumKeyEx")]
extern public static int RegEnumKeyEx(
int hkey,
int index,
StringBuilder lpName,
ref int lpcbName,
int reserved,
int lpClass,
int lpcbClass,
out long lpftLastWriteTime);
'@
$type2 = Add-Type -MemberDefinition $sig2 -Name Win32Utils `
-Namespace RegEnumKeyEx -Using System.Text -PassThru
$sig3 = @'
[DllImport("advapi32.dll", SetLastError=true)]
public static extern int RegCloseKey(
int hKey);
'@
$type3 = Add-Type -MemberDefinition $sig3 -Name Win32Utils `
-Namespace RegCloseKey -Using System.Text -PassThru
$hKey = new-object int
$hKeyref = new-object int
$searchKeyRemote = $type0::RegConnectRegistry($computer, $searchKey, ` [ref]$hKey)
$result = $type1::RegOpenKeyEx($hKey, $SubKey, 0, $KEYREAD, ` [ref]$hKeyref)
#initialize variables
$builder = New-Object System.Text.StringBuilder 1024
$index = 0
$length = [int] 1024
$time = New-Object Long
#234 means more info, 0 means success. Either way, keep reading
while ( 0,234 -contains $type2::RegEnumKeyEx($hKeyref, $index++, ` $builder, [ref] $length, $null, $null, $null, [ref] $time) )
{
#create output object
$o = "" | Select Key, LastWriteTime, ComputerName
$o.ComputerName = "$computer"
$o.Key = $builder.ToString()
# TODO Change to use the time api
$o.LastWriteTime = (Get-Date $time).AddYears(1600).AddHours(-4)
$o
#reinitialize for next time through the loop
$length = [int] 1024
$builder = New-Object System.Text.StringBuilder 1024
}
$result = $type3::RegCloseKey($hKey);
}
}
} # End Get-RegKeyLastWriteTime function
Alles anzeigen