PHP Code:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Email versender")
$Input1 = GUICtrlCreateInput("", 8, 40, 121, 21)
$Input2 = GUICtrlCreateInput("", 248, 40, 121, 21)
$Label1 = GUICtrlCreateLabel("Mail sever: Für www.web.de ist er smtp.web.de ", 8, 16, 229, 17)
$Label2 = GUICtrlCreateLabel("Name des Absenders", 248, 16, 105, 17)
$Label3 = GUICtrlCreateLabel("Absender email addresse", 8, 72, 122, 17)
$Input3 = GUICtrlCreateInput("", 8, 96, 121, 21)
$Input4 = GUICtrlCreateInput("", 248, 96, 121, 21)
$Label4 = GUICtrlCreateLabel("Empfänger email addresse", 248, 72, 128, 17)
$Input5 = GUICtrlCreateInput("", 8, 152, 121, 21)
$Label5 = GUICtrlCreateLabel("Betreff", 8, 128, 35, 17)
$Label6 = GUICtrlCreateLabel(" Text ", 248, 128, 34, 17)
$Input6 = GUICtrlCreateInput("", 248, 152, 121, 21)
$Label7 = GUICtrlCreateLabel("Nochmal Absender email", 8, 184, 121, 17)
$Input7 = GUICtrlCreateInput("", 8, 208, 121, 21)
$Input8 = GUICtrlCreateInput("", 248, 208, 121, 21)
$Label8 = GUICtrlCreateLabel("Passwort der Absender email", 248, 184, 140, 17)
$Button1 = GUICtrlCreateButton("Email versenden", 152, 248, 100, 25, 0)
$Button2 = GUICtrlCreateButton("Abbrechen", 312, 256, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$rc = _INetSmtpMailCom(GUICtrlRead( $Input1),GUICtrlRead($Input2),GUICtrlRead($Input3), GUICtrlRead($Input4), GUICtrlRead($Input5), GUICtrlRead($Input6), "", "","", GUICtrlRead($Input7), GUICtrlRead($Input8))
If @error then
msgbox(0,"Error sending message","Error code:" & @error & " Description:" & $rc)
EndIf
Case $Button2
Exit
EndSwitch
WEnd
Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Username = "", $s_Password = "")
$objEmail = ObjCreate("CDO.Message")
$objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
$objEmail.To = $s_ToAddress
Local $i_Error = 0
Local $i_Error_desciption = ""
If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
If $s_BccAddress <> "" Then $objEmail.Cc = $s_BccAddress
$objEmail.Subject = $s_Subject
If StringInStr($as_Body,"<") and StringInStr($as_Body,">") Then
$objEmail.HTMLBody = $as_Body
Else
$objEmail.Textbody = $as_Body & @CRLF
EndIf
If $s_AttachFiles <> "" Then
Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
For $ex = 1 To $S_Files2Attach[0]
$S_Files2Attach[$x] = _PathFull ($S_Files2Attach[$x])
If FileExists($S_Files2Attach[$x]) Then
$objEmail.AddAttachment ($S_Files2Attach[$x])
Else
$i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $S_Files2Attach[$x]
SetError(1)
return 0
EndIf
Next
EndIf
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
;Authenticated SMTP
If $s_Username <> "" Then
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
EndIf
;Update settings
$objEmail.Configuration.Fields.Update
; Sent the Message
$objEmail.Send
if @error then
SetError(2)
return $oMyRet[1]
EndIf
EndFunc;==>_INetSmtpMailCom
;
;
; Com Error Handler
Func MyErrFunc()
$HexNumber = Hex($oMyError.number, 8)
$oMyRet[0] = $HexNumber
$oMyRet[1] = StringStripWS($oMyError.description,3)
ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF)
SetError(1); something to check for when this function returns
Return
EndFunc;==>MyErrFunc