Hallo alle zusammen,
ich hab dieses Skript:
Spoiler anzeigen
Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ;#include <_pop3.au3> #include <_INetSmtpMailCom.au3> ;################################## ; Variables ;################################## $SmtpServer = "smtp.web.de" ; address for the smtp-server to use - REQUIRED $FromName = "" ; name from who the email was sent $FromAddress = "myName@web.de" ; address from where the mail should come $ToAddress = "taAdress@gmx.de" ; destination address of the email - REQUIRED $Subject = "Userinfo" ; subject from the email - can be anything you want it to be $Body = "Test" ; the messagebody from the mail - can be left blank but then you get a blank mail $AttachFiles = "" ; the file you want to attach- leave blank if not needed $CcAddress = "" ; address for cc - leave blank if not needed $BccAddress = "" ; address for bcc - leave blank if not needed $Importance = "Normal" ; Send message priority: "High", "Normal", "Low" $Username = "myName@web.de" ; username for the account used from where the mail gets sent - REQUIRED $Password = "PassWort" ; password for the account used from where the mail gets sent - REQUIRED $IPPort = 587 ; port used for sending the mail normaly 25 $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 ;################################## ; Script ;################################## ;_pop3Connect("pop3.live.com", $Username, $Password) $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
[/autoit]
von AutoBert aus diesem Thread: KLICK
Jetzt ist meine Frage wie ich das somachen kann das man auswählen kann ob man AttachFiles hat oder nicht.
Ich hab eine GUI, wo eine Checkbox ist, wo man wählen kann ob man eine Datei anhängen möchte. Immer wenn ich dann die Checkbox unaktivert lasse, kommt ein Fehler das die Variable die ich dem OpenFileDialog zugewiesen habe, nicht deklariert ist.
Hier mal die Funktion dazu:
Spoiler anzeigen
If (GUICtrlRead($Screenshot)) = $GUI_CHECKED Then
$message = "Bitte wählen Sie den Screeshot."
$var = FileOpenDialog($message, "C:\", "Bilder (*.jpg;*.bmp)", 1 + 4 )
If @error Then
MsgBox(0, "Fehler!", "Es ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut.")
$var = ""
Exit
Else
$var = StringReplace($var, "|", @CRLF)
EndIf
Else
MsgBox(64, "Nicht aktiviert", "Test")
EndIf
;##################################
; Variables
;##################################
$Antwort = GUICtrlRead($Auswahl_System)
$Name_Abteilung = GUICtrlRead($Abteilung)
$SmtpServer = "smtp.web.de" ; address for the smtp-server to use - REQUIRED
$FromName = @UserName ; name from who the email was sent
$FromAddress = "xxx" ; address from where the mail should come
$ToAddress = "xxx" ; destination address of the email - REQUIRED
$Subject = "Supportmeldung: " & @ComputerName ; subject from the email - can be anything you want it to be
$Body = "Datum: " & @MDAY & "." & @MON & "." & @YEAR & @CRLF & "Uhrzeit: " & @HOUR & ":" & @MIN & @CRLF & "Benutzername: " & @UserName & @CRLF & "Computername: "& @ComputerName & @CRLF & "IP Addresse: " & @IPAddress1 & @CRLF & "System: "& $Antwort & @CRLF & "Fehlerbeschreibung: " & GUICtrlRead($Fehlerbescheibung)
; the messagebody from the mail - can be left blank but then you get a blank mail
$AttachFiles = $var ; the file you want to attach- leave blank if not needed
$CcAddress = "" ; address for cc - leave blank if not needed
$BccAddress = "" ; address for bcc - leave blank if not needed
$Importance = "Normal" ; Send message priority: "High", "Normal", "Low"
$Username = "xxx" ; username for the account used from where the mail gets sent - REQUIRED
$Password = "xxx" ; password for the account used from where the mail gets sent - REQUIRED
$IPPort = 587 ; port used for sending the mail normaly 25
$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
;##################################
; Script
;##################################
$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)
Else
MsgBox(64, "Erfolgreich", "Die Supportmitteilung wurde erfolgreich an die Fachinformatik übermittelt. Bitte haben Sie gedult, wir setzten und sofort mit Ihnen in Verbindung.")
EndIf
Ich hoffe ihr wisst was ich meine und könnt mir helfen.
Lg und danke