Problem mit Umlauten beim Versenden von E-Mail?

  • Hallo Leute,

    ich habe das Problem, wenn ich mit der Script (siehe unten) von Schnitzel die E-mail verschicke, das die Umlaute im Betreff und der Nachrichtentext in der erhaltende E-Mail (siehe das Bild ganz unten) nicht korrekt dargestellt sind.
    Lässt sich dies beheben?

    [Blockierte Grafik: http://www.imgbox.de/users/public/images/3KLInWOt4U.jpg]

    E-Mail.au3

    [autoit]

    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_icon=send-mail.ico
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #include <Array.au3>
    #include <GUIConstantsEx.au3>
    #include <Inet.au3>
    Global $section, $combodata
    $section = IniReadSection("Email.ini", "Emails")
    Dim $Checkbox[$Section[0][0]+1]
    _ArraySort($section, 0, 0, 0, 0)

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

    $Form1 = GUICreate("e-mail Programm", 400, Round($section[0][0]/2)*20+290)
    For $i = 1 To $Section[0][0]
    $Checkbox[$i] = GUICtrlCreateCheckbox($Section[$i][0], 205 - Mod($i, 2)*200, 5 + (Round($i/2) - 1)*20, 190, 25)
    Next
    $label1 = GUICtrlCreateLabel("_________________________________________________________________", 5, (Mod($section[0][0], 2) +Round($i/2) - 1)*20 +4, 390, 25)
    $label2 = GUICtrlCreateLabel("Betreff:", 5, 18 + (Mod($section[0][0], 2) +Round($i/2) - 1)*20, 390, 25)
    GUICtrlSetColor(-1, 0x1B79D9)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Input1 = GUICtrlCreateInput(IniRead("Email.ini", "Standards", "Betreff", ""), 5, 35 + (Mod($section[0][0], 2) +Round($i/2) - 1)*20, 390, 25)
    GUICtrlSetBkColor(-1, 0xFFFFE1)
    $label2 = GUICtrlCreateLabel("Nachrichttext:", 5, 78 + (Mod($section[0][0], 2) +Round($i/2) - 1)*20, 390, 25)
    GUICtrlSetColor(-1, 0x1B79D9)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Edit1 = GUICtrlCreateEdit(StringReplace(IniRead("Email.ini", "Standards", "Nachricht", ""), " |@CRLF| ", @CRLF) , 5, 95 + (Mod($section[0][0], 2) +Round($i/2) - 1)*20, 390, 100)
    GUICtrlSetBkColor(-1, 0xFFFFE1)
    $label3 = GUICtrlCreateLabel("Empfänger:", 5, 213 + (Mod($section[0][0], 2) +Round($i/2) - 1)*20, 390, 25)
    GUICtrlSetColor(-1, 0x1B79D9)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Input2 = GUICtrlCreateInput("", 5, 230 + (Mod($section[0][0], 2) +Round($i/2) - 1)*20, 390, 25)
    GUICtrlSetBkColor(-1, 0xA6CAF0)
    $Button1 = GUICtrlCreateButton("Standards speichern", 5, 260 + (Mod($section[0][0], 2) +Round($i/2) - 1)*20, 150, 25)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $Button3 = GUICtrlCreateButton("ini öffnen", 170, 260 + (Mod($section[0][0], 2) +Round($i/2) - 1)*20, 90, 25)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $Button2 = GUICtrlCreateButton("Email senden", 275, 260 + (Mod($section[0][0], 2) +Round($i/2) - 1)*20, 120, 25)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0xC0DCC0)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Checkbox[1] To $Checkbox[$Section[0][0]]
    $emails = ""
    For $i = 1 To $Section[0][0]
    If BitAnd(GUICtrlRead($Checkbox[$i]), $GUI_CHECKED) Then
    $emails &= $Section[$i][1] & "; "
    EndIf
    Next
    Guictrlsetdata($Input2, $emails)
    Case $Button1
    IniWrite("Email.ini", "Standards", "Betreff", GUICtrlRead($Input1))
    IniWrite("Email.ini", "Standards", "Nachricht", StringReplace(GUICtrlRead($Edit1), @CRLF, " |@CRLF| "))
    Case $Button2
    _INetMail(GUICtrlRead($Input2), GUICtrlRead($Input1), GUICtrlRead($Edit1) & @CRLF)
    WinWaitActive("[CLASS:rctrl_renwnd32]")
    Send("^{End}")
    Send("{ALTDOWN}h{ALTUP}g")
    sleep(500)
    Send("{ENTER}")
    sleep(500)
    Send("!s")
    Case $Button3
    Shellexecute(@ScriptDir & "\Email.ini")
    EndSwitch
    WEnd

    [/autoit]

    Email.ini

    [autoit]


    [Emails]
    Klaus=klaus@anbieter.de
    Peter=peter@anbieter.de
    Claudia=claudia@anbieter.de
    Susi=susi@anbieter.de
    Rodi=rodi@anbieter.de
    [Standards]
    Betreff=Projekt 60125 Köln Bürogebäude ist angelegt
    Nachricht=Projektnr.: 60125 |@CRLF| Projektname: Köln Bürogebäude |@CRLF| ist unter T:\PRJ\2012 angelegt.

    [/autoit]

    [Blockierte Grafik: http://www.imgbox.de/users/public/images/5O4w3r3g6M.jpg]


    Viele Grüße,
    Dino

  • Lt. Helpfile für _InetMail: "Öffnet das Standard-E-Mail Programm mit vorgegebener Adresse, Überschrift und Inhalt."
    Was ist Dein Standard Email Programm und welchen Mailtyp versendet es (Text, RFT, HTML)?

  • Vielleicht liegts ja am Charset... Aber da _InetMail() das Standard-EmailProgramm benützt um Emails zu versenden, hab ich mal das Script so umgeändert, dass es ohne Email-Programm Emails verschickt und zusätzlich das Charset ISO 8859-1 benützt....
    Musst halt die Daten von deinem Email Acc eintragen.
    Du kannst es ja einfach mal probieren, ob sich was tut:D

    [autoit]

    #include <INet.au3>
    #include <Array.au3>
    #include <GUIConstantsEx.au3>

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

    $s_SmtpServer = "" ;http://www.hoffmann-software.de/FrEewARE/Liste…SMTP-Server.htm
    $s_FromName = ""
    $s_FromAddress = ""
    $s_UName = ""
    $s_PWD = ""

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

    Global $section, $combodata
    $section = IniReadSection("Email.ini", "Emails")
    Dim $Checkbox[$section[0][0] + 1]
    _ArraySort($section, 0, 0, 0, 0)

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

    $Form1 = GUICreate("e-mail Programm", 400, Round($section[0][0] / 2) * 20 + 290)
    For $i = 1 To $section[0][0]
    $Checkbox[$i] = GUICtrlCreateCheckbox($section[$i][0], 205 - Mod($i, 2) * 200, 5 + (Round($i / 2) - 1) * 20, 190, 25)
    Next
    $label1 = GUICtrlCreateLabel("_________________________________________________________________", 5, (Mod($section[0][0], 2) + Round($i / 2) - 1) * 20 + 4, 390, 25)
    $label2 = GUICtrlCreateLabel("Betreff:", 5, 18 + (Mod($section[0][0], 2) + Round($i / 2) - 1) * 20, 390, 25)
    GUICtrlSetColor(-1, 0x1B79D9)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Input1 = GUICtrlCreateInput(IniRead("Email.ini", "Standards", "Betreff", ""), 5, 35 + (Mod($section[0][0], 2) + Round($i / 2) - 1) * 20, 390, 25)
    GUICtrlSetBkColor(-1, 0xFFFFE1)
    $label2 = GUICtrlCreateLabel("Nachrichttext:", 5, 78 + (Mod($section[0][0], 2) + Round($i / 2) - 1) * 20, 390, 25)
    GUICtrlSetColor(-1, 0x1B79D9)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Edit1 = GUICtrlCreateEdit(StringReplace(IniRead("Email.ini", "Standards", "Nachricht", ""), " |@CRLF| ", @CRLF), 5, 95 + (Mod($section[0][0], 2) + Round($i / 2) - 1) * 20, 390, 100)
    GUICtrlSetBkColor(-1, 0xFFFFE1)
    $label3 = GUICtrlCreateLabel("Empfänger:", 5, 213 + (Mod($section[0][0], 2) + Round($i / 2) - 1) * 20, 390, 25)
    GUICtrlSetColor(-1, 0x1B79D9)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Input2 = GUICtrlCreateInput("", 5, 230 + (Mod($section[0][0], 2) + Round($i / 2) - 1) * 20, 390, 25)
    GUICtrlSetBkColor(-1, 0xA6CAF0)
    $Button1 = GUICtrlCreateButton("Standards speichern", 5, 260 + (Mod($section[0][0], 2) + Round($i / 2) - 1) * 20, 150, 25)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $Button3 = GUICtrlCreateButton("ini öffnen", 170, 260 + (Mod($section[0][0], 2) + Round($i / 2) - 1) * 20, 90, 25)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $Button2 = GUICtrlCreateButton("Email senden", 275, 260 + (Mod($section[0][0], 2) + Round($i / 2) - 1) * 20, 120, 25)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetBkColor(-1, 0xC0DCC0)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Checkbox[1] To $Checkbox[$section[0][0]]
    $emails = ""
    For $i = 1 To $section[0][0]
    If BitAND(GUICtrlRead($Checkbox[$i]), $GUI_CHECKED) Then
    $emails &= $section[$i][1] & "; "
    EndIf
    Next
    GUICtrlSetData($Input2, $emails)
    Case $Button1
    IniWrite("Email.ini", "Standards", "Betreff", GUICtrlRead($Input1))
    IniWrite("Email.ini", "Standards", "Nachricht", StringReplace(GUICtrlRead($Edit1), @CRLF, " |@CRLF| "))
    Case $Button2
    Dim $as_Body[1]
    $as_Body[0] = GUICtrlRead($Edit1) & @CRLF

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

    $as_ToAddress = StringSplit(GUICtrlRead($Input2), ";")
    If StringStripWS($as_ToAddress[$as_ToAddress[0]], 8) = "" Then
    _ArrayPop($as_ToAddress)
    $as_ToAddress[0] -= 1
    EndIf

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

    For $i_i = 1 To $as_ToAddress[0]
    _INetSmtpMailAuth($s_SmtpServer, $s_FromName, $s_FromAddress, $as_ToAddress[$i_i], $s_UName, $s_PWD, GUICtrlRead($Input1), $as_Body)
    If @error Then
    MsgBox(0, "Error!", "Mail failed with error code " & @error)
    ExitLoop
    Else
    MsgBox(0, "Success!", "Mail sent")
    EndIf
    Next
    ;_INetMail(GUICtrlRead($Input2), GUICtrlRead($Input1), GUICtrlRead($Edit1) & @CRLF)

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

    Case $Button3
    ShellExecute(@ScriptDir & "\Email.ini")
    EndSwitch
    WEnd

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

    ;===============================================================================
    ;
    ; Function Name: _INetSmtpMailAuth()
    ; Description: Sends an email using SMTP over TCP IP.
    ; Parameter(s): $s_SmtpServer - SMTP server to be used for sending email
    ; $s_FromName - Name of sender
    ; $s_FromAddress - eMail address of sender
    ; $s_ToAddress - Address that email is to be sent to
    ; $s_Username - Username for Authentication (bernd670)
    ; $s_Passwd - Password for Authentication (bernd670)
    ; $s_Subject - Subject of eMail
    ; $as_Body - Single dimension array containing the body of eMail as strings
    ; $s_helo - Helo identifier (default @COMPUTERNAME) sometime needed by smtp server
    ; $s_first - send before Helo identifier (default @CRLF) sometime needed by smtp server
    ; $b_trace - trace on a splash window (default 0 = no trace)
    ; Requirement(s): None
    ; Return Value(s): On Success - Returns 1
    ; On Failure - 0 and sets
    ; @ERROR = 1 - Invalid Parameters
    ; @ERROR = 2 - Unable to start TCP
    ; @ERROR = 3 - Unable to resolve IP
    ; @ERROR = 4 - Unable to create socket
    ; @ERROR = 5x - Cannot open SMTP session
    ; @ERROR = 50x - Cannot send body
    ; @ERROR = 5000 - Cannot close SMTP session
    ; Authors: Original function to send email via TCP - Asimzameer
    ; Conversion to UDF - Walkabout
    ; Correction Helo, timeout, trace - Jpm
    ; Correction send before Helo - Jpm
    ; Include Authentication - bernd670
    ;
    ;===============================================================================
    Func _INetSmtpMailAuth($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Username, $s_Passwd, $s_Subject = "", $as_Body = "", $s_helo = "", $s_first = "-1", $b_trace = 0)

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

    Local $v_Socket
    Local $s_IPAddress
    Local $i_Count
    Local $s_Send[9]
    Local $s_ReplyCode[9];Return code from SMTP server indicating success

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

    If $s_SmtpServer = "" Or $s_FromAddress = "" Or $s_ToAddress = "" Or $s_Username = "" Or $s_Passwd = "" Or $s_FromName = "" Or StringLen($s_FromName) > 256 Then
    SetError(1)
    Return 0
    EndIf
    If $s_helo = "" Then $s_helo = @ComputerName
    If TCPStartup() = 0 Then
    SetError(2)
    Return 0
    EndIf
    StringRegExp($s_SmtpServer, "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)")
    If @extended Then
    $s_IPAddress = $s_SmtpServer
    Else
    $s_IPAddress = TCPNameToIP($s_SmtpServer)
    EndIf
    If $s_IPAddress = "" Then
    TCPShutdown()
    SetError(3)
    Return 0
    EndIf
    $v_Socket = TCPConnect($s_IPAddress, 25)
    If $v_Socket = -1 Then
    TCPShutdown()
    SetError(4)
    Return (0)
    EndIf

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

    $s_Send[0] = "EHLO " & $s_helo & @CRLF
    $s_ReplyCode[0] = "250"

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

    $s_Send[1] = "AUTH LOGIN" & @CRLF
    $s_ReplyCode[1] = "334"
    $s_Send[2] = _Base64Encoding($s_Username) & @CRLF
    $s_ReplyCode[2] = "334"
    $s_Send[3] = _Base64Encoding($s_Passwd) & @CRLF
    $s_ReplyCode[3] = "235"
    $s_Send[4] = "MAIL FROM: <" & $s_FromAddress & ">" & @CRLF
    $s_ReplyCode[4] = "250"
    $s_Send[5] = "RCPT TO: <" & $s_ToAddress & ">" & @CRLF
    $s_ReplyCode[5] = "250"
    $s_Send[6] = "DATA" & @CRLF
    $s_ReplyCode[6] = "354"

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

    $s_Send[7] = "From: " & $s_FromName & " <" & $s_FromAddress & ">" & @CRLF & _
    "To: " & "<" & $s_ToAddress & ">" & @CRLF & _
    "Subject: " & $s_Subject & @CRLF & _
    "Mime-Version: 1.0" & @CRLF & _
    "Content-Type: text/plain; charset=ISO 8859-1" & @CRLF & _ ;<---------------------CHARSET-------------------
    @CRLF
    $s_ReplyCode[7] = ""

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

    $s_Send[8] = @CRLF & "." & @CRLF
    $s_ReplyCode[8] = "250"

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

    ; open stmp session
    If __SmtpSend($v_Socket, $s_Send[0], $s_ReplyCode[0], $b_trace, "220", $s_first) Then
    SetError(50)
    Return 0
    EndIf

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

    ; send header
    For $i_Count = 0 To UBound($s_Send) - 2
    If __SmtpSend($v_Socket, $s_Send[$i_Count], $s_ReplyCode[$i_Count], $b_trace) Then
    SetError(50 + $i_Count)
    Return 0
    EndIf
    Next

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

    ; send body records (a record can be multiline : take care of a subline beginning with a dot should be ..)
    For $i_Count = 0 To UBound($as_Body) - 1
    ; correct line beginning with a dot
    If StringLeft($as_Body[$i_Count], 1) = "." Then $as_Body[$i_Count] = "." & $as_Body[$i_Count]

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

    If __SmtpSend($v_Socket, $as_Body[$i_Count] & @CRLF, "", $b_trace) Then
    SetError(500 + $i_Count)
    Return 0
    EndIf
    Next

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

    ; close the smtp session
    $i_Count = UBound($s_Send) - 1
    If __SmtpSend($v_Socket, $s_Send[$i_Count], $s_ReplyCode[$i_Count], $b_trace) Then
    SetError(5000)
    Return 0
    EndIf

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

    TCPCloseSocket($v_Socket)
    TCPShutdown()
    Return 1
    EndFunc ;==>_INetSmtpMailAuth

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

    ;===============================================================================
    ;
    ; Function Name: _Base64Encoding()
    ; Description: Kodiert eine Zeichenfolge mit dem Base64-Verfahren
    ; (http://de.wikipedia.org/wiki/Base64)
    ; Parameter(s): $String - Zeichenfolge die kodiert werden soll
    ; Requirement(s): None
    ; Return Value(s): Kodierte Zeichenfolge
    ; Authors: bernd670
    ;
    ;===============================================================================
    Func _Base64Encoding($String)

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

    $strUmsetzung = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
    $strRetValue = ""

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

    For $i = 1 To StringLen($String) Step 3
    $strTok = StringMid($String, $i, 3)
    Switch StringLen($strTok)
    Case 3
    $iTokVal = (Asc(StringMid($strTok, 1, 1)) * 256 + _
    Asc(StringMid($strTok, 2, 1))) * 256 + _
    Asc(StringMid($strTok, 3, 1))
    $strTokCryt = StringMid($strUmsetzung, (BitAND($iTokVal, 63)) + 1, 1)
    $iTokVal = BitShift($iTokVal, 6)
    $strTokCryt = StringMid($strUmsetzung, (BitAND($iTokVal, 63)) + 1, 1) & $strTokCryt
    $iTokVal = BitShift($iTokVal, 6)
    $strTokCryt = StringMid($strUmsetzung, (BitAND($iTokVal, 63)) + 1, 1) & $strTokCryt
    $iTokVal = BitShift($iTokVal, 6)
    $strTokCryt = StringMid($strUmsetzung, (BitAND($iTokVal, 63)) + 1, 1) & $strTokCryt
    $strRetValue &= $strTokCryt

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

    Case 2
    $iTokVal = (Asc(StringMid($strTok, 1, 1)) * 256 + _
    Asc(StringMid($strTok, 2, 1))) * 256
    $iTokVal = BitShift($iTokVal, 6)
    $strTokCryt = StringMid($strUmsetzung, (BitAND($iTokVal, 63)) + 1, 1)
    $iTokVal = BitShift($iTokVal, 6)
    $strTokCryt = StringMid($strUmsetzung, (BitAND($iTokVal, 63)) + 1, 1) & $strTokCryt
    $iTokVal = BitShift($iTokVal, 6)
    $strTokCryt = StringMid($strUmsetzung, (BitAND($iTokVal, 63)) + 1, 1) & $strTokCryt
    $strRetValue &= $strTokCryt & "="

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

    Case 1
    $iTokVal = Asc(StringMid($strTok, 1, 1)) * 65536
    $iTokVal = BitShift($iTokVal, 12)
    $strTokCryt = StringMid($strUmsetzung, (BitAND($iTokVal, 63)) + 1, 1)
    $iTokVal = BitShift($iTokVal, 6)
    $strTokCryt = StringMid($strUmsetzung, (BitAND($iTokVal, 63)) + 1, 1) & $strTokCryt
    $strRetValue &= $strTokCryt & "=="

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

    EndSwitch
    Next

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

    Return $strRetValue
    EndFunc ;==>_Base64Encoding

    [/autoit]
    Zitat

    You just keep on trying 'till you run out of cake. ;)


    [STEAM] Source UDF

    4 Mal editiert, zuletzt von K4z (17. Januar 2012 um 17:21)

  • Mein Mailprogramm ist Outlook 2010 und die E-Mail die ankommt ist im Rich-Text-Format.
    Die Script sollen mehrere Leute benutzen. Die Account Daten von Benutzer zu Benutzer sind unterschiedlich.
    Geht das ohne Eingabe der Mail-Account-Daten?

  • Du kannst ja mal mein OutlookEX UDF versuchen (Link für Download siehe Signatur). Function _OL_Wrapper_SendMail sollte alles können was Du brauchst.

  • Warum nicht einfach die Mailfunktion von PHP verwenden? Einfach ein PHP Script auf einem Server laufen lassen, an dieses die notwendigen Daten übergeben (in der URL) und die Mail versenden lassen. Das Ganze braucht keinerlei Passwörter.