Variable teilen?

  • Kann mir jemand helfen? Es kam ein neues Problem, siehe bitte meinen letzten Post

    [autoit]

    $1 = "xy@gmx.de"
    $2 = ;Diese Variable soll den Anbieter ermitteln, also so was in der Art: [email='xy@gmx.de'][/email] - xy@ - .de
    If $2 = "gmx" Then
    ; ...
    If $2 = "web" Then
    ; ...
    If $2 = "googlemail" Then
    ; ...
    EndIf

    [/autoit]

    Danke im Vorraus!

    6 Mal editiert, zuletzt von meinnameisthase (12. Mai 2011 um 20:40)

  • Vielleicht so:

    [autoit]


    $1 = "xy@gmx.de"
    $2 = StringRegExpReplace($1, "(.+@)(.+)(\..+)", "$2")

    [/autoit]

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • OK, danke, noch eine Frage:

    [autoit]

    If $2 = "gmx","web","googlemail" Then ; Oder so ähnlich :)
    Else
    MsgBox (0,"","Der Mailserver wurde nicht gefunden")
    EndIf

    [/autoit]

    Wie muss ich das machen, dass es läuft?

    Einmal editiert, zuletzt von meinnameisthase (12. Mai 2011 um 15:57)

  • Nein, so geht das nicht, es wäre ja auch gar nicht definiert, was bei einem positiven Vergleich geschehen soll.
    Du benutzt am besten entweder eine If-Abfrage:

    [autoit]


    If $2 = "web" Then
    ;...
    ElseIf $2 = "gmx" Then
    ;...
    Else
    ;....
    EndIf

    [/autoit]

    oder eine Select-Abfrage:

    [autoit]


    Select
    Case $2 = "web"
    ;...
    Case $2 = "gmx"
    ;...
    EndSelect

    [/autoit]



    oder eine Switch-Abfrage (hier mein Favorit)

    [autoit]


    Switch $2
    Case "gmx"
    ;...
    Case "web"
    ;...
    EndSwitch

    [/autoit]


    Edit: Ups, wohl falschverstanden :huh:
    Benutze statt den "," einfach

    [autoit]

    Or

    [/autoit]

    s:

    [autoit]

    If $2 = "gmx" Or $2 ="web" Or $2 = "googlemail" Then ; Oder so ähnlich :)
    Else
    MsgBox (0,"","Der Mailserver wurde nicht gefunden")
    EndIf

    [/autoit]
  • Wie muss ich das machen, dass es läuft?

    Spoiler anzeigen
    [autoit]

    $vVariable = "xyz"

    [/autoit] [autoit][/autoit] [autoit]

    If $vVariable = "Eins" Or $vVariable = "Zwei" Or $vVariable = "Drei" Then
    ; ...
    Else
    ; ...
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ; Oder

    [/autoit] [autoit][/autoit] [autoit]

    Switch $vVariable
    Case "Eins", "Zwei", "Drei"
    ; ...
    Case Else
    ; ...
    EndSwitch

    ; Oder

    [/autoit] [autoit][/autoit] [autoit]

    If StringInStr("Eins,Zwei,Drei",$vVariable) Then
    ; ....
    EndIf

    [/autoit] [autoit][/autoit] [autoit][/autoit]
  • Ich würde es so machen:

    [autoit]


    #include <Array.au3>
    Dim $a[5] = ["gmx", "web", "hotmail", "googlemail", "yahoo"]
    $1 = "xy@gmx.de"
    $2 = StringRegExpReplace($1, "(.+@)(.+)(\..+)", "$2")
    $s = _ArrayToString($a) & "|"
    If StringInStr($s, $2) Then
    MsgBox (0, "", "Der Mailserver " & $2 & " wurde gefunden!")
    Else
    MsgBox (0,"","Der Mailserver " & $2 & " wurde nicht gefunden!")
    EndIf

    [/autoit]

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • Warum läuft das nicht???

    [autoit]

    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include<file.au3>

    [/autoit][autoit][/autoit][autoit]

    Global $oMyRet[2]
    Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

    [/autoit][autoit][/autoit][autoit]

    $SmtpServer = "mail.gmx.de"
    $IPPort = 25 ; port used for sending the mail
    $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS
    $Importance = "Normal"
    $AttachFiles = "" ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed

    [/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit][autoit]

    GUICreate("Quick- & Safe Mail", 463, 474, 885, 121)
    $1 = GUICtrlCreateInput("", 176, 40, 265, 21, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL))
    $2 = GUICtrlCreateInput("", 176, 8, 265, 21)
    GUICtrlCreateLabel("Ihre E-Mail Adresse", 8, 8, 98, 25)
    GUICtrlCreateLabel("Ihr Passwort", 8, 40, 62, 25)
    $3 = GUICtrlCreateInput("", 176, 104, 265, 21)
    GUICtrlCreateLabel("E-Mail Adresse des Empfängers", 8, 112, 153, 17)
    $4 = GUICtrlCreateInput("", 176, 232, 265, 21)
    GUICtrlCreateLabel("Betreff", 8, 232, 35, 17)
    $5 = GUICtrlCreateEdit("", 176, 264, 265, 153)
    GUICtrlSetData(-1, "")
    GUICtrlCreateLabel("Ihre Nachricht", 8, 272, 71, 17)
    $6 = GUICtrlCreateInput("", 176, 72, 265, 21)
    GUICtrlCreateLabel("Ihr Name", 8, 72, 47, 17)
    $los = GUICtrlCreateButton("Verschicken", 0, 440, 305, 33)
    $7 = GUICtrlCreateButton("Anhang", 304, 440, 153, 33, $WS_GROUP)
    $8 = GUICtrlCreateInput("", 176, 136, 265, 21)
    $9 = GUICtrlCreateInput("", 176, 168, 265, 21)
    GUICtrlCreateLabel("ggf. Emfpänger 2", 8, 144, 85, 17)
    GUICtrlCreateLabel("ggf. Empfänger 3", 8, 176, 85, 17)
    GUISetState(@SW_SHOW)

    [/autoit][autoit][/autoit][autoit]

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    Case $7
    $AttachFiles = FileOpenDialog("Wählen Sie eine Datei für den Anhang.", @DesktopDir & "\", "Alle Dateien (*.*)")
    Case $los
    ; #########################################################################################################################################################
    $checken = StringRegExpReplace($FromAddress, "(.+@)(.+)(\..+)", "$2")

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    If $checken = "gmx" Then
    $SmtpServer = "mail.gmx.de"
    $Username = GUICtrlRead ($FromAddress)
    $IPPort = 25
    $ssl = 0 ; SSl ja/nein | https: 1 - http: 0
    EndIf
    If $checken = "web" Then
    $SmtpServer = "smtp.web.de"
    $Username = GUICtrlRead ($FromAddress)
    $IPPort = 25
    $ssl = 0 ; SSl ja/nein | https: 1 - http: 0
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If $checken = "googlemail" Then
    $SmtpServer = "smtp.googlemail.com"
    $Username = GUICtrlRead ($FromAddress)
    $IPPort = 465
    $ssl = 1 ; SSl ja/nein | https: 1 - http: 0

    EndIf

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    If $checken = "gmx" Or $checken = "web" Or $checken = "googlemail" Then
    Else
    MsgBox (0,"Save- & Quickmail","Der Malserver '"& $2 &"' wird von Safe- & Quickmail nicht unterstützt. Melden Sie '"& $2 &"' doch auf http://hegi.de.to/. Dann wird '" & $2 & "' vieleicht auch bald unterstützt.")
    EndIf
    ; ######################################################################################################################################################################


    TrayTip ("Safe- & Quickmail","Nachricht wird gesendet... Wichtig: Bei Dateien mit Anhang dauert dieser Vorgang etwas länger.",10000)
    $Password = GUICtrlRead($1)
    $FromAddress = GUICtrlRead($2)
    $ToAddress = GUICtrlRead($3)
    $Subject = GUICtrlRead($4)
    $body = GUICtrlRead($5)
    $FromName = GUICtrlRead($6)
    $Anhang = GUICtrlRead($7)
    $CcAddress = GUICtrlRead($8)
    $BccAddress = GUICtrlRead($9)

    [/autoit][autoit][/autoit][autoit]

    $Username = GUICtrlRead($2)
    $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
    If @error Then
    MsgBox(0, "Da ging wohl was schief...", "Fehler Code: " & @error & " Beschreibung: " & $rc & " Kontaktieren Sie ggf. den Hersteller der Software.")
    Else
    EndIf
    EndSwitch
    WEnd

    [/autoit][autoit][/autoit][autoit]

    ;
    ; The UDF
    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
    TrayTip ("Safe- & Quickmail","Senden fehlgeschlagen",10000)
    SetError(2)
    Return $oMyRet[1]
    EndIf
    $objEmail = ""
    TrayTip ("Quick- & Safe Mail","Nachricht erfolgreich gesendet!",10000)
    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

    [/autoit]

    Einmal editiert, zuletzt von meinnameisthase (12. Mai 2011 um 20:01)