Da der Code 20000 Zeilen hat, kann ich dir nur den kurzen Auszug posten. Sorry
Spoiler anzeigen
Func sendemail($sAdresse, $sBetreff, $sNachrText, $sAnhang)
If ProcessExists("outlook.exe") = 0 Then
ShellExecute("outlook.exe") ; Wenn Outlook nicht gestartet, öffne Outlook
EndIf
Local $Betreff = GUICtrlRead($iSendmail_TXT)
Global $oOutlook = _OL_Open()
_OL_MailSignatureSet("entsel-2", "") ; in Outlook vorhandene Signatur
$oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", "Subject=" & $Betreff)
Local $aRecipients ;empfänger_1
Local $MailCC = GUICtrlRead($iST_Email_2) ;empfänger
If $sAdresse <> "" Then
$aRecipients = StringSplit($sAdresse, ";", 2)
If $MailCC = "" Then
_OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olTo, $aRecipients)
Else
_OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olTo, $aRecipients)
_OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olCC, $MailCC)
EndIf
EndIf
Local $aAttachments ;anhang
If $sAnhang <> "" Then
$aAttachments = StringSplit($sAnhang, ";", 2)
;~ _Arraydisplay($aAttachments)
_OL_ItemAttachmentAdd($oOutlook, $oItem, Default, $aAttachments)
If @error = 3 Then
MsgBox(0 + 262144 + 64, "Fehler", "Eine Datei ist zum Versenden zu groß")
Return
EndIf
If @error = 4 Then
MsgBox(0 + 262144 + 64, "Fehler", "Eine Datei ist nicht vorhanden")
Return
EndIf
EndIf
;Check wenn Mail versendet wird
Global $oOApp = ObjCreate("Outlook.Application")
Global $oItems = $oOApp.GetNamespace("MAPI").GetDefaultFolder($olFolderSentMail).Items
Local $Event = ObjEvent($oItems, "oItems_")
$oItem.BodyFormat = $olFormatHTML
$oItem.GetInspector
$sBody = $oItem.HTMLBody
$oItem.HTMLBody = $sNachrText & $sBody
_OL_MailSignatureSet("entsel-1", "entsel-1") ; zurückstellen auf Standard-Signatur
Global $SendMailFile = $SaveAsMail & $Betreff & ".msg"
If FileExists($SendMailFile) Then
If 7 = MsgBox(4 + 262144 + 32, "Mail überschreiben", "Die Datei " & $Betreff & ".msg ist schon vorhanden." & @CRLF & @CRLF & "Soll sie überschrieben werden") Then ;nicht vorhanden
MsgBox(0 + 262144 + 64, "Mail", "Bitte versuchen sie es erneut mit anderen Betreff")
ExitLoop
Else
FileDelete($SendMailFile)
Sleep(100)
_OL_ItemSave($oOutlook, $oItem, Default, $SendMailFile, $olMSGUnicode)
Sleep(100)
$oItem.Display
ExitLoop
EndIf
Else
_OL_ItemSave($oOutlook, $oItem, Default, $SendMailFile, $olMSGUnicode)
Sleep(100)
$oItem.Display
EndIf
endFunc