Jump to content

_INetSmtpMail error


Recommended Posts

Hi all,

I get the folowing error code when i'm trying to send mail using the mentioned function: Unable to create socket

Why?

All fields are filled in correctly. I used the autoit example from the helpfile.

Thanks!

Edited by PcExpert
Link to comment
Share on other sites

Try setting $b_trace to see the smtp session dialog, that may give you a better idea of where the problem is. Also check that your firewall is not preventing outgoing smtp connection.

$Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @ComputerName, -1, $ts)
Link to comment
Share on other sites

This function has been working for three or four times now, but now it suddenly doesnt send it any more. I get the same arror again (socket error) so I thought to turn on trace. But it seems that my scite is a little bit messed up, because the syntax tooltip isnt accurate. I'm sure the syntax is fine, but it doesnt show the debug window, why? The option is set to 1.

Link to comment
Share on other sites

This modified version of the Autoit example with "trace send" option works for me.

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

$s_SmtpServer = "mysmtpserver.com.au"
$s_FromName = "My Name"
$s_FromAddress = "From eMail Address"
$s_ToAddress = "To eMail Address"
$s_Subject = "Test AutoIt InetSmtpMail"

GUICreate("", 500, 150)
$edit = GUICtrlCreateEdit ("", 10, 10, 480, 100)
$btn_send = GUICtrlCreateButton ("Send", 10,118,50)
$btn_trace = GUICtrlCreateButton ("Trace Send", 70,118,70)
GUISetState ()

while 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $btn_send
            $trace = 0
            Email()
        Case $msg = $btn_trace
            $trace = 1
            Email()
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

Func Email()
    $txt = GUICtrlRead($edit)
    Dim $as_Body[1]
    $as_Body[0] = $txt
    $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, "EHLO" & @ComputerName, -1, $trace)
    $err = @error
    If $Response = 1 Then
        MsgBox(262144, "Success!", "Mail sent")
    Else
        MsgBox(262144, "Error!", "Mail failed with error code " & $err)
    EndIf
EndFunc
Link to comment
Share on other sites

Doesnt work. I'll post my Send mail code:

$s_SmtpServer = "mail.server"
$s_FromName = GUICtrlRead($naam)
$s_FromAddress = GUICtrlRead($email)
$s_ToAddress = "toaddr"
$s_Subject = "Subject"
Dim $as_Body[11]
$as_Body[0] = "TEXT Line 1"
$as_Body[1] = ""
$as_Body[2] = "Text Line 2"
$as_Body[3] = ""
$as_Body[4] = "TEXT LINE 3"
$as_Body[5] = ""
$as_Body[6] = ""
$as_Body[7] = "TEXT LINE 4"
$as_Body[8] = ""
$as_Body[9] = "TEXT LINE 5"
$as_Body[10] = "TEXT LINE 6"
$Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, "EHLO" & @ComputerName, -1, 1)
$err = @error
If $Response = 1 Then
    MsgBox(0, $appname, $ERR_License_Aanvraag_done)
    Exit
Else
    MsgBox(0, $appname, $ERR_License_Aanvraag_error & $err)
    Exit
EndIf
EndFunc

Thanks!

Edited by PcExpert
Link to comment
Share on other sites

  • Developers

Doubt we can test it for you unless you run an Open/relay SMTP server (which in not advisable), but this doesn't look right to me:

"EHLO" & @ComputerName

should be:

"EHLO " & @ComputerName

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Dunno...it does for me. what have you done to try and debug that ?

Its a lot more effective when you try to do some debugging yourself in stead of posting here since we cannot test your code really and have no idea of your setup ....

Just copy the include file and add some consolewrite statements (Alt+D in SciTE) to see what is happening....

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...