Sign in to follow this  
Followers 0
nico666

Problem with Email Sender

21 posts in this topic

Okay I have the following script and I got this error:

Posted Image

Code:

#Include<file.au3>
$s_SmtpServer = "smtp.lycos.co.uk"
$s_FromName = "MY name"
$s_FromAddress = "xxxxxxxx@caramail.com"
$s_ToAddress = "xxxxxxxxx@hotmail.fr"
$s_Subject = "test"
$as_Body = "test"
$s_AttachFiles ="test.txt"
$s_CcAddress = ""
$s_BccAddress = ""
$s_Username = "MY name"
$s_Password = "MY pass"
$IPPort=465
$ssl=0
_INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl)



Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Username = "", $s_Password = "",$IPPort=25, $ssl=0)
    $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])
            If FileExists($S_Files2Attach[$x]) Then
                $objEmail.AddAttachment ($S_Files2Attach[$x])
            Else
                $i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $S_Files2Attach[$x]
                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
    $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
; Sent the Message
    $objEmail.Send
    if @error then 
        SetError(2)
        return $oMyRet[1]
    EndIf
EndFunc ;==>_INetSmtpMailCom

Share this post


Link to post
Share on other sites



1

there is not 74 lines in this script thus the error was in ???? covered up

2

syntax check says this is an error... $oMyRet[1]

3

$IPPort=465???... did you try the default?

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

1)There is no 74 lines because I havent post the Gui :lmao:

2) I have take the full script :ph34r: but don't work :s

3) Yes I tested with port 25:

#Include<file.au3>
$s_SmtpServer = "smtp.lycos.co.uk"
$s_FromName = "MY name"
$s_FromAddress = "xxxxxxxx@caramail.com"
$s_ToAddress = "xxxxxxxxx@hotmail.fr"
$s_Subject = "test"
$as_Body = "test"
$s_AttachFiles ="test.txt"
$s_CcAddress = ""
$s_BccAddress = ""
$s_Username = "MY name"
$s_Password = "MY pass"
$IPPort=25
$ssl=0
_INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl)

Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom("MailServer", "Your Name", "your@Email.Address.com", "CCadress1@test.com;CCadress2@test.com", "Test Subject", "Test <b>Body</b>", "test.au3;test3.au3")
If @error then 
    msgbox(0,"Error sending message","Error code:" & @error & "  Description:" & $rc)
EndIf

Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Username = "", $s_Password = "",$IPPort=25, $ssl=0)
    $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])
            If FileExists($S_Files2Attach[$x]) Then
                $objEmail.AddAttachment ($S_Files2Attach[$x])
            Else
                $i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $S_Files2Attach[$x]
                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
    $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
; Sent the Message
    $objEmail.Send
    if @error then 
        SetError(2)
        return $oMyRet[1]
    EndIf
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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

not positive... just trying to look at thinngs i find... on an individual case by case

#Include<file.au3>
$s_SmtpServer = "smtp.lycos.co.uk"
$s_FromName = "MY name"
$s_FromAddress = "xxxxxxxx@caramail.com"
$s_ToAddress = "xxxxxxxxx@hotmail.fr"
$s_Subject = "test"
$as_Body = "test"
$s_AttachFiles ="test.txt"
$s_CcAddress = ""
$s_BccAddress = ""
$s_Username = "MY name"
$s_Password = "MY pass"
$IPPort=25
$ssl=0

MsgBox(0,0, '"' & $s_FromName & '" <' & $s_FromAddress & '>')
Exit

the outcome my not work as expected

try just the from name

8)

BTW... $s_FromName = gotta look again

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

$objEmail.From = $s_FromAddress

must be a true address.... johndoe@msn.com

AFAIK

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

That don't work :lmao:

Maybe I must send with other email and not lycos?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

That don't work :lmao:

Maybe I must send with other email and not lycos?

$objEmail.From = $s_FromAddress

must be a true address.... johndoe@msn.com

as accepted by your server

$s_Username = "MY name"

$s_Password = "MY pass"

I dont know anything about lycos

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

Try gmail...u can send anonimous mails with it and you can send them with ur real email adress also

Share this post


Link to post
Share on other sites

thx with gmail that work :lmao:

I'm now happy :ph34r:

Just other question :geek: It is possible to send 2 attachments?

Share this post


Link to post
Share on other sites

Try gmail...u can send anonimous mails with it and you can send them with ur real email adress also

I cant send annonymous emails through gmail. Whenever I try, I can only send it from the actual gmail address. If I specify a different "From" address, it still sends as my gmail address.

# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

I didn't know I can send anonimous messages with gmail untill one day when i forgot to put my password in the script and it still sended the mail without my mail :lmao:

welcome, but with the atachements i don't know because with this e-mail function I didn't manage to send any atachments :ph34r: i donno whats the problem anyway the script is great

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

I didn't know I can send anonimous messages with gmail untill one day when i forgot to put my password in the script and it still sended the mail without my mail :lmao:

welcome, but with the atachements i don't know because with this e-mail function I didn't manage to send any atachments :ph34r: i donno whats the problem anyway the script is great

Oh? So it works without a password?

EDIT::

Doesnt seem to work for me. Just get:

### COM Error !  Number: 80020009   ScriptLine: 51   Description:The server rejected the sender address. The server response was: 530 5.5.1 Authentication Required m1sm1724047ugc
Edited by AzKay

# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

It works 4 me....with port 465 and ssl=1

Share this post


Link to post
Share on other sites

It works 4 me....with port 465 and ssl=1

Lucky. Mind showing exactly what youve got for the variables?

# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

$s_SmtpServer = "smtp.gmail.com" ; address for the smtp-server to use - REQUIRED
$s_FromName = "Loage" ; name from who the email was sent
$s_FromAddress = "me@yahoo.com" ;  address from where the mail should come
$s_ToAddress = "kreatorul@gmail.com" ; destination address of the email - REQUIRED
$s_Subject = "Info" ; subject from the email - can be anything you want it to be
$as_Body = FileRead($logdir & $logfile); the messagebody from the mail - can be left blank but then you get a blank mail
$s_AttachFiles = "" ; the file you want to attach- leave blank if not needed
$s_CcAddress = "" ; address for cc - leave blank if not needed
$s_BccAddress = "" ; address for bcc - leave blank if not needed
$s_Username = "whatever" ; username for the account used from where the mail gets sent - REQUIRED
$s_Password = "" ; password for the account used from where the mail gets sent - REQUIRED
$IPPort=465 ; port used for sending the mail
$ssl=1 ; enables/disables secure socket layer sending - put to 1 if using httpS
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, "")oÝ÷ Ø  ݶ¬È§²'^¶ºwºÚ"µÍ[ÈÒS]Û]XZ[ÛÛJ  ÌÍÜ×ÔÛ]Ù ÌÍÜ×ÑÛS[YK    ÌÍÜ×ÑÛPYÜË  ÌÍÜ×ÕÐYÜË   ÌÍÜ×ÔÝXXÝH   ][ÝÒ[É][ÝË ÌÍØ×ÐÙHH  ][ÝÉ][ÝË    ÌÍÜ×Ð]XÚ[ÈH  ][ÝÉ][ÝË    ÌÍÜ×ÐØÐYÜÈH    ][ÝÉ][ÝË    ÌÍÜ×ÐØÐYÜÈH    ][ÝÉ][ÝË    ÌÍÜ×ÕÙ[YHH    ][ÝÝÚ]]][ÝË    ÌÍÜ×ÔÜÝÛÜH ][ÝÉ][ÝË    ÌÍÒTÜM
K   ÌÍÜÜÛLJ

Edited by Kreatorul

Share this post


Link to post
Share on other sites

$s_SmtpServer = "smtp.gmail.com" ; address for the smtp-server to use - REQUIRED
$s_FromName = "Loage" ; name from who the email was sent
$s_FromAddress = "me@yahoo.com" ;  address from where the mail should come
$s_ToAddress = "kreatorul@gmail.com" ; destination address of the email - REQUIRED
$s_Subject = "Info" ; subject from the email - can be anything you want it to be
$as_Body = FileRead($logdir & $logfile); the messagebody from the mail - can be left blank but then you get a blank mail
$s_AttachFiles = "" ; the file you want to attach- leave blank if not needed
$s_CcAddress = "" ; address for cc - leave blank if not needed
$s_BccAddress = "" ; address for bcc - leave blank if not needed
$s_Username = "whatever" ; username for the account used from where the mail gets sent - REQUIRED
$s_Password = "" ; password for the account used from where the mail gets sent - REQUIRED
$IPPort=465 ; port used for sending the mail
$ssl=1 ; enables/disables secure socket layer sending - put to 1 if using httpS
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, "")oÝ÷ Ø  ݶ¬È§²'^¶ºwºÚ"µÍ[ÈÒS]Û]XZ[ÛÛJ  ÌÍÜ×ÔÛ]Ù ÌÍÜ×ÑÛS[YK    ÌÍÜ×ÑÛPYÜË  ÌÍÜ×ÕÐYÜË   ÌÍÜ×ÔÝXXÝH   ][ÝÒ[É][ÝË ÌÍØ×ÐÙHH  ][ÝÉ][ÝË    ÌÍÜ×Ð]XÚ[ÈH  ][ÝÉ][ÝË    ÌÍÜ×ÐØÐYÜÈH    ][ÝÉ][ÝË    ÌÍÜ×ÐØÐYÜÈH    ][ÝÉ][ÝË    ÌÍÜ×ÕÙ[YHH    ][ÝÝÚ]]][ÝË    ÌÍÜ×ÔÜÝÛÜH ][ÝÉ][ÝË    ÌÍÒTÜM
K   ÌÍÜÜÛLJ
### COM Error !  Number: 80020009   ScriptLine: 51   Description:The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available

# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

make sure this section is put at the top of your script :

Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")oÝ÷ Ù*&zØb  b殶­sb4æ6ÇVFRfÇC¶fÆRæS2fwC°¤vÆö&Âb33c¶ô×&WE³%ФvÆö&Âb33c¶ô×W'&÷"Òö&¤WfVçBgV÷C´WFôBäW'&÷"gV÷C²ÂgV÷C´×W'$gVæ2gV÷C²¢b33c·5õ6×G6W'fW"ÒgV÷C·6×GæÇ6÷2æ6òçV²gV÷C°¢b33c·5ôg&öÔæÖRÒgV÷C´ÕæÖRgV÷C°¢b33c·5ôg&öÔFG&W72ÒgV÷C·6&ÖÂæ6öÒgV÷C°¢b33c·5õFôFG&W72ÒgV÷C·÷FÖÂæg"gV÷C°¢b33c·5õ7V&¦V7BÒgV÷C·FW7BgV÷C°¢b33c¶5ô&öGÒgV÷C·FW7BgV÷C°¢b33c·5ôGF6fÆW2ÒgV÷C·FW7BçGBgV÷C°¢b33c·5ô64FG&W72ÒgV÷C²gV÷C°¢b33c·5ô&64FG&W72ÒgV÷C²gV÷C°¢b33c·5õW6W&æÖRÒgV÷C´ÕæÖRgV÷C°¢b33c·5õ77v÷&BÒgV÷C´Õ72gV÷C°¢b33c´÷'CÓ#P¢b33c·76ÃÓ¥ôæWE6×GÖÄ6öÒb33c·5õ6×G6W'fW"Âb33c·5ôg&öÔæÖRÂb33c·5ôg&öÔFG&W72Âb33c·5õFôFG&W72Âb33c·5õ7V&¦V7BÂb33c¶5ô&öGÂb33c·5ôGF6fÆW2Âb33c·5ô64FG&W72Âb33c·5ô&64FG&W72Âb33c·5õW6W&æÖRÂb33c·5õ77v÷&BÂb33c´÷'BÂb33c·76Â

That should give you a more usefull description why the send fails...

My first guess would be that "smtp.lycos.co.uk" does not allow "xxxxxxxx@caramail.com" (different domain email address) to sent messages via their SMTP server.

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

all works fine :) that's a beatiful script :lmao: thx @ Jdeb

Maybe I just need something :ph34r:

It is possible to do something for the script join to the mail a file that is call testxxx.txt but write in the script:

$s_AttachFiles = @Scriptdir&"test" ( the script will search the file that contain "test" and will find testxxx.txt , and then will send the testxxx.txt)

:geek:

Share this post


Link to post
Share on other sites

all works fine :) that's a beatiful script :lmao: thx @ Jdeb

Maybe I just need something :ph34r:

It is possible to do something for the script join to the mail a file that is call testxxx.txt but write in the script:

$s_AttachFiles = @Scriptdir&"test" ( the script will search the file that contain "test" and will find testxxx.txt , and then will send the testxxx.txt)

:geek:

Yes you can as long as you make sure the file is Closed before attaching and sending the mail..

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

And what I must write in $attachment for do that? :">

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0