Sorry, das mit dem Quellcode hab ich verplant. Habs im ersten Thread auch schon angepasst.
Hier jetzt das komplette Script(gerne nehme ich auch allgemeine Verbesserungsvorschläge an):
Spoiler anzeigen
#include <ButtonConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <GUIListView.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include<file.au3>
;##################################
;GUI Design
;##################################
Global $nm_firstname, $nm_lastname, $nm_username, $nm_entry, $no_reference, $akt_firstname, $akt_lastname, $akt_username, $domain_acc, $LN_acc, $ln_grouplist, $psnext_acc, $vpn_acc, $telefon, $adminlist, $Start, $Exit
Global $customersupport, $psnextadmin
Global $SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl
_main ()
Func _main ()
#Region ### START Koda GUI section ### Form=h:\1data\public\autoit\forms\new_user.kxf
$Form1_1 = GUICreate("Bestellung neuer Accounts", 1051, 511, 190, 123)
$nm_firstname = GUICtrlCreateInput("", 144, 72, 121, 21)
$nm_lastname = GUICtrlCreateInput("", 144, 112, 121, 21)
$nm_username = GUICtrlCreateInput("", 144, 152, 121, 21)
GUICtrlSetLimit(-1, 9)
$nm_entry = GUICtrlCreateDate(@MDAY, 144, 192, 186, 21)
$no_reference = GUICtrlCreateCheckbox("Kein Referenzbenutzer", 424, 72, 153, 17)
$akt_firstname = GUICtrlCreateInput("", 480, 112, 121, 21)
$akt_lastname = GUICtrlCreateInput("", 480, 152, 121, 21)
$akt_username = GUICtrlCreateInput("", 480, 192, 121, 21)
GUICtrlSetLimit(-1, 9)
$domain_acc = GUICtrlCreateCheckbox("", 256, 256, 97, 17)
$LN_acc = GUICtrlCreateCheckbox("", 256, 296, 97, 17)
$ln_grouplist = GUICtrlCreateList("", 72, 328, 273, 149, BitOR($GUI_SS_DEFAULT_LIST,$LBS_MULTIPLESEL))
GUICtrlSetData(-1, "LN-Group1|LN-Group2|LN-Group3|LN-Group4")
$psnext_acc = GUICtrlCreateCheckbox("", 544, 256, 97, 17)
$vpn_acc = GUICtrlCreateCheckbox("", 544, 296, 97, 17)
$telefon = GUICtrlCreateCheckbox("", 544, 336, 97, 17)
$adminlist = GUICtrlCreateList("", 808, 72, 121, 58)
GUICtrlSetData(-1, "Admin1|Admin2|Admin3|Admin4")
;$admin_pw = GUICtrlCreateInput("", 808, 152, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) ;Wird nicht benötigt
$Start = GUICtrlCreateButton("Start", 800, 272, 193, 73)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
$Exit = GUICtrlCreateButton("Exit", 800, 368, 193, 73)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("Vorname*:", 56, 72, 49, 17)
$Label2 = GUICtrlCreateLabel("Nachname*:", 56, 112, 59, 17)
$Label3 = GUICtrlCreateLabel("Username*:", 56, 152, 55, 17)
$Label4 = GUICtrlCreateLabel("Eintritt:", 56, 192, 36, 17)
$Label5 = GUICtrlCreateLabel("Vorname:", 392, 112, 49, 17)
$Label6 = GUICtrlCreateLabel("Nachname:", 392, 152, 59, 17)
$Label7 = GUICtrlCreateLabel("Username:", 392, 192, 55, 17)
$Label8 = GUICtrlCreateLabel("versenden von:", 712, 72, 78, 17)
;$Label9 = GUICtrlCreateLabel("Passwort:", 712, 152, 50, 17) ;Wird nicht benötigt
$Label10 = GUICtrlCreateLabel("New Domain Account", 72, 256, 108, 17)
$Label11 = GUICtrlCreateLabel("New Lotus Notes Account", 72, 296, 129, 17)
$Label12 = GUICtrlCreateLabel("New PSNext Account", 376, 256, 108, 17)
$Label13 = GUICtrlCreateLabel("New VPN Account", 376, 296, 94, 17)
$neuer = GUICtrlCreateGroup("neuer Mitarbeiter", 40, 40, 313, 201)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group1 = GUICtrlCreateGroup("Berechtigung übernehmen von", 376, 40, 265, 201)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label14 = GUICtrlCreateLabel("New phone", 376, 336, 59, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;##################################
;Standardvariablen
;##################################
$SmtpServer = "xxx.xxx.xxx.xxx" ; address for the smtp-server to use - REQUIRED
$Importance = "Normal" ; Send message priority: "High", "Normal", "Low"
$CcAddress = "" ; address for cc - leave blank if not needed
$IPPort = 25 ; port used for sending the mail
$ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS
;~ $IPPort=465 ; GMAIL port used for sending the mail
;~ $ssl=1 ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS
$customersupport = "test@gmail.com"
$psnextadmin = "test@gmail.com"
;##################################
;Username überprüfen
;##################################
$WMI = ObjGet("WinMgmts:root/cimv2")
$colQuery1 = $WMI.ExecQuery("Select UserName FROM Win32_ComputerSystem")
For $item In $colQuery1
$ID = $item.UserName
Next
$colQuery2 = $WMI.ExecQuery("Select * FROM Win32_NetworkLoginProfile")
For $object In $colQuery2
If $object.Name = $ID Then ;MsgBox(0, "", $object.Fullname)
$Name = $object.Fullname
EndIf
Next
;##################################
;Checkboxen aktivieren / aktuellen Benutzer selektieren
;##################################
GUICtrlSetData($adminlist, $Name)
_GUICtrlListBox_SetSel($ln_grouplist, 3)
GUIctrlsetstate($domain_acc, $GUI_CHECKED)
GUIctrlsetstate($LN_acc, $GUI_CHECKED)
GUIctrlsetstate($psnext_acc, $GUI_CHECKED)
GUIctrlsetstate($vpn_acc, $GUI_CHECKED)
GUIctrlsetstate($telefon, $GUI_CHECKED)
;##################################
;Waren auf Knopfdruck
;##################################
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $no_reference
If GUICtrlRead($no_reference) = 1 Then
GUIctrlsetstate($akt_firstname, $GUI_DISABLE)
GUIctrlsetstate($akt_lastname, $GUI_DISABLE)
GUIctrlsetstate($akt_username, $GUI_DISABLE)
Else
GUIctrlsetstate($akt_firstname, $GUI_ENABLE)
GUIctrlsetstate($akt_lastname, $GUI_ENABLE)
GUIctrlsetstate($akt_username, $GUI_ENABLE)
EndIf
Case $Start
;##################################
;GUI auslesen
;##################################
$nm_firstname = GUICtrlRead($nm_firstname)
If $nm_firstname = "" Then
MsgBox(16, "Sie haben ein Pflichtfeld vergessen", "Der Vorname des neuen Mitarbeiters ist ein Pflichtfeld")
_main ()
Exit
EndIf
$nm_lastname = GUICtrlRead($nm_lastname)
$nm_username = GUICtrlRead($nm_username)
$nm_entry = GUICtrlRead($nm_entry)
$akt_firstname = GUICtrlRead($akt_firstname)
$akt_lastname = GUICtrlRead($akt_lastname)
$akt_username = GUICtrlRead($akt_username)
$domain_acc = GUICtrlRead($domain_acc)
$LN_acc = GUICtrlRead($LN_acc)
$psnext_acc = GUICtrlRead($psnext_acc)
$vpn_acc = GUICtrlRead($vpn_acc)
$telefon = GUICtrlRead($telefon)
$adminlist = GUICtrlRead($adminlist)
$FromName = $adminlist ; name from who the email was sent
;Umwandeln des Namens in Mailadresse
Local $fname = StringSplit($adminlist, " ")
$Mailname = $fname[1] & "." & $fname[2]
$Mailname = StringLower($Mailname)
$Mailname = $Mailname & "@gmail.com"
Global $FromAddress = $Mailname ; address from where the mail should come
Global $Username = $adminlist ; username for the account used from where the mail gets sent - REQUIRED
Global $Password = "" ; password for the account used from where the mail gets sent - REQUIRED
Global $BccAddress = $Mailname ; address for bcc - leave blank if not needed
Global $signatur = FileRead("C:\Tools\Bestellung neuer Accounts\" & $adminlist & ".txt")
Local $sItems, $aItems, $hListBox
$aItems = _GUICtrlListBox_GetSelItemsText($ln_grouplist)
For $iI = 1 To $aItems[0]
If $iI > 1 Then $sItems &= ", "
$sItems &= $aItems[$iI]
$ln_grouplist = $sItems
Next
If $LN_acc = $GUI_CHECKED And $ln_grouplist = "12" Then
MsgBox(16, "Keine Gruppe für Lotus Notes gewählt", "Das Programm wird geschlossen da keine Gruppe für Lotus Notes gewählt wurde.")
Exit
EndIf
_check ()
MsgBox(0, "neue Accounts bestellt", "Alle Emails wurden erfolgreich gesendet. Bitte eigenen Posteingang prüfen.")
Exit
Case $Exit
Exit
EndSwitch
WEnd
;##################################
;Überprüfen welche Checkbox aktiv ist und dann entsprechende Funktion aufrufen
;##################################
Func _check ()
If $domain_acc = "1" Then
_domainacc ()
EndIf
If $LN_acc = "1" Then
_notesacc ()
EndIf
If $psnext_acc = "1" Then
_psnextacc ()
EndIf
If $vpn_acc = "1" Then
_vpnacc ()
EndIf
If $telefon = "1" Then
_telefon ()
EndIf
EndFunc
;##################################
;Domainaccount bestellen
;##################################
Func _domainacc ()
;Setze Variablen für Mail
$textteil1 = "Sehr geehrte Damen und Herren," & @CRLF & @CRLF & "blabla" & @CRLF
$textteil2 = "Name: " & $nm_lastname & @CRLF
$textteil3 = "Vorname: " & $nm_firstname & @CRLF
$textteil4 = "Username: " & $nm_username & @CRLF
$textteil5 = "blabla" & @CRLF
$textteil6 = "Eintritt: " & $nm_entry & @CRLF
If GUICtrlRead($no_reference) = $GUI_CHECKED Then
$textteil7 = ""
Else
$textteil7 = "Bitte übernehmen Sie die Berechtigungen von: " & $akt_firstname & " " & $akt_lastname & " " & $akt_username & "." & @CRLF
EndIf
$textteil8 = @CRLF & "Danke im Voraus."
$bodytext = $textteil1 & $textteil2 & $textteil3 & $textteil4 & $textteil5 & $textteil6 & $textteil7 & $textteil8 & $signatur
$ToAddress = $customersupport ; destination address of the email - REQUIRED
$Subject = "New Domain Account " & $nm_firstname & " " & $nm_lastname & " " & $nm_username ; subject from the email - can be anything you want it to be
$Body = $bodytext ; the messagebody from the mail - can be left blank but then you get a blank mail
$AttachFiles = "" ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed
;##################################
; Aufruf Sendmail
;##################################
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
If @error Then
MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc)
EndIf
EndFunc
;##################################
;Lotus Notes Account bestellen
;##################################
Func _notesacc ()
;Setze Variablen für Mail
$textteil1 = "Sehr geehrte Damen und Herren," & @CRLF & @CRLF & "blabla" & @CRLF
$textteil2 = "Name: " & $nm_lastname & @CRLF
$textteil3 = "Vorname: " & $nm_firstname & @CRLF
$textteil4 = "Eintritt: " & $nm_entry & @CRLF
$textteil5 = "blabla" & @CRLF
$textteil6 = "blabla" & @CRLF
$textteil7 = "Aufnahme in die Mailgruppe(n): " & $ln_grouplist & @CRLF
$textteil8 = @CRLF & "Danke im Voraus."
$bodytext = $textteil1 & $textteil2 & $textteil3 & $textteil4 & $textteil5 & $textteil6 & $textteil7 & $textteil8 & $signatur
$ToAddress = $customersupport ; destination address of the email - REQUIRED
$Subject = "New Notes Account " & $nm_firstname & " " & $nm_lastname ; subject from the email - can be anything you want it to be
$Body = $bodytext ; the messagebody from the mail - can be left blank but then you get a blank mail
$AttachFiles = "" ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed
;##################################
; Aufruf Sendmail
;##################################
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
If @error Then
MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc)
EndIf
EndFunc
;##################################
;PSNext Account bestellen
;##################################
Func _psnextacc ()
;Setze Variablen für Mail
$textteil1 = "blabla" & @CRLF & @CRLF & "blabla " & @CRLF
$textteil2 = "Name: " & $nm_lastname & @CRLF
$textteil3 = "Vorname: " & $nm_firstname & @CRLF
$textteil4 = "Username: " & $nm_username & @CRLF
$textteil5 = "blabla" & @CRLF
$textteil6 = @CRLF & "Danke im Voraus."
$bodytext = $textteil1 & $textteil2 & $textteil3 & $textteil4 & $textteil5 & $textteil6 & $signatur
$ToAddress = $psnextadmin ; destination address of the email - REQUIRED
$Subject = "blabla " & $nm_firstname & " " & $nm_lastname & " " & $nm_username ; subject from the email - can be anything you want it to be
$Body = $bodytext ; the messagebody from the mail - can be left blank but then you get a blank mail
$AttachFiles = "" ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed
;##################################
; Aufruf Sendmail
;##################################
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
If @error Then
MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc)
EndIf
EndFunc
;##################################
;VPN Account bestellen
;##################################
Func _vpnacc ()
;Setze Variablen für Mail
$textteil1 = "Sehr geehrte Damen und Herren," & @CRLF & @CRLF & "blabla:" & @CRLF
$textteil2 = "Name: " & $nm_lastname & @CRLF
$textteil3 = "Vorname: " & $nm_firstname & @CRLF
$textteil4 = "Username: " & $nm_username & @CRLF & @CRLF
$textteil5 = "blabla" & @CRLF
$textteil6 = @CRLF & "Danke im Voraus."
$bodytext = $textteil1 & $textteil2 & $textteil3 & $textteil4 & $textteil5 & $textteil6 & $signatur
$ToAddress = $psnextadmin ; destination address of the email - REQUIRED
$Subject = "blabla " & $nm_firstname & " " & $nm_lastname & " " & $nm_username ; subject from the email - can be anything you want it to be
$Body = $bodytext ; the messagebody from the mail - can be left blank but then you get a blank mail
$AttachFiles = "" ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed
;##################################
; Aufruf Sendmail
;##################################
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
If @error Then
MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc)
EndIf
EndFunc
;##################################
;Telefon bestellen
;##################################
Func _telefon ()
;Setze Variablen für Mail
$textteil1 = "Sehr geehrte Damen und Herren," & @CRLF & @CRLF & "blabla" & @CRLF
$textteil2 = "Name: " & $nm_lastname & @CRLF
$textteil3 = "Vorname: " & $nm_firstname & @CRLF
$textteil4 = "Username: " & $nm_username & @CRLF
$textteil5 = "Eintritt: " & $nm_entry & @CRLF & @CRLF
$textteil6 = "blabla" & @CRLF
$textteil7 = @CRLF & "Danke im Voraus."
$bodytext = $textteil1 & $textteil2 & $textteil3 & $textteil4 & $textteil5 & $textteil6 & $textteil7 & $signatur
$ToAddress = $psnextadmin ; destination address of the email - REQUIRED
$Subject = "New telephone " & $nm_firstname & " " & $nm_lastname ; subject from the email - can be anything you want it to be
$Body = $bodytext ; the messagebody from the mail - can be left blank but then you get a blank mail
$AttachFiles = "" ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed
;##################################
; Aufruf Sendmail
;##################################
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
If @error Then
MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc)
EndIf
EndFunc
;##################################
;Sendmail
;##################################
Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0)
Local $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.Bcc = $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 $x = 1 To $S_Files2Attach[0]
$S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
;~ ConsoleWrite('@@ Debug : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console
If FileExists($S_Files2Attach[$x]) Then
ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF)
$objEmail.AddAttachment($S_Files2Attach[$x])
Else
ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF)
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
If Number($IPPort) = 0 then $IPPort = 25
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
;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
If $ssl Then
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
EndIf
;Update settings
$objEmail.Configuration.Fields.Update
; Set Email Importance
Switch $s_Importance
Case "High"
$objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High"
Case "Normal"
$objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal"
Case "Low"
$objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low"
EndSwitch
$objEmail.Fields.Update
; Sent the Message
$objEmail.Send
If @error Then
SetError(2)
Return $oMyRet[1]
EndIf
$objEmail=""
EndFunc ;==>_INetSmtpMailCom
; Com Error Handler
Func MyErrFunc()
$HexNumber = Hex($oMyError.number,
$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