- Offizieller Beitrag
Hi,
Da ich für meinen GMX-Account _INetSmtpMailCom( ) nicht verwenden kann, habe ich mal SendEmail( ) probiert.
Spoiler anzeigen
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
Func SendEmail($e_Sender, $e_Recipient, $e_Subject, $e_Text,$e_File)
$objMessage = ObjCreate ("CDO.Message")
With $objMessage
.Subject = $e_Subject
.Sender = $e_Sender
.From = $e_Sender
.To = $e_Recipient
.TextBody = $e_Text
;.HtmlBody = $e_Text ; uncomment to send a HTML mail and comment line above
;~ .AddAttachment = $e_File
EndWith
With $objMessage.Configuration.Fields
.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.gmx.net";$smtpserver
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "max.mustermann@gmx.de";$smtpuser
.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "XXX";$smtppass
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Update
EndWith
$objMessage.Send
Return
EndFunc
Func MyErrFunc()
$HexNumber=hex($oMyError.number,8) ; for displaying purposes
Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _
"err.description is: " & @TAB & $oMyError.description & @CRLF & _
"err.number is: " & @TAB & $HexNumber & @CRLF & _
"err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF _
)
SetError(1) ; to check for after this function returns
Endfunc
Dabei taucht aber ein seltsames Phänomen auf:
Übergebe ich die Daten für die eMail im Klartext
[autoit]SendEmail("max.mustermann@gmx.de", "empfaenger@web.de", "Betreff = TEST", "Body = Das ist ein Test")
[/autoit]dann funktioniert das tadellos.
Rufe ich die Funktion aber mit Variablen, die ich mit Daten aus einer INI befüllt habe auf:
SendEmail($arIniRead[1][1], $arIniRead[2][1], $Betr, $Text)
[/autoit]erhalte ich: "==> The requested action with this object has failed.:
$objMessage.Send
$objMessage.Send^ ERROR"
Wenn ich den Fehler auswerte: "...Server hat die Absender adresse zurückgewiesen ...unknown user"
Und die Daten in der INI sind identisch mit denen, die ich im ersten Bsp. von Hand eintrage. :irre:
Hat jemand 'ne Idee?
*Die Funktion verwendet im Original noch "Attachment". Das hab ich aber auskommentiert, da ich es nicht brauche. Deshalb Aufruf nur mit 4 Argumenten.