Jump to content

sending email fails with error code 50


Recommended Posts

Hi,

I am trying to send an email using this script below (took it from the help sample), but it fails with error code 50. Any help to get around this please? $as_body is optional, so whether i use it or not, i get error code 50 in both cases.

================================

#include <INet.au3>

$s_SmtpServer = "xxx.xxx.xxx.xx" ;using a valid IP address

$s_FromName = "TEST"

$s_FromAddress = "testing1@test.com" ;using a valid email address

$s_ToAddress = "testing2@test.com" ;using a valid email address

$s_Subject = "Test Results"

;$as_Body = "Testing the auto email"

$Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject)

$err = @error

If $Response = 1 Then

MsgBox(0, "Success!", "Mail sent")

Else

MsgBox(0, "Error!", "Mail failed with error code " & $err)

EndIf

Link to comment
Share on other sites

50x - Cannot send body. x indicates the line number of $as_Body (first line is 0).

You are missing an important point of this function:

$as_Body [optional] The body of the email as a single dimensional array of strings. Each value in the array will be terminated with a @CRLF in the email.

It might be optional but it wouldn't hurt to declare an array for the body - the error message is clearly related to the body of the message. What does it happen when you use the script from the help file but change only the server and from/to? Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

Hello,

this script works:

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

#include <_INetSmtpMailCom.au3>

;##################################
; Variables
;##################################
$SmtpServer = ""              ; address for the smtp-server to use - REQUIRED
$FromName = "autoBert"                      ; name from who the email was sent
$FromAddress = "anyBody@hotmail.com" ; address from where the mail should come
$ToAddress = "anotherBoy@hotmail.ocm"   ; destination address of the email - REQUIRED
$Subject = "Userinfo"                   ; subject from the email - can be anything you want it to be
$Body = "Test"                              ; the messagebody from the mail - can be left blank but then you get a blank mail
$AttachFiles = ""                       ; the file you want to attach- leave blank if not needed
$CcAddress = ""       ; address for cc - leave blank if not needed
$BccAddress = ""     ; address for bcc - leave blank if not needed
$Importance = "Normal"                  ; Send message priority: "High", "Normal", "Low"
$Username = "MyAccountName"                    ; username for the account used from where the mail gets sent - REQUIRED
$Password = "TopSecret"                  ; password for the account used from where the mail gets sent - REQUIRED
$IPPort = 25                            ; port used for sending the mail normaly 25
$ssl = 1                                ; enables/disables secure socket layer sending - put to 1 if using httpS
;~ $IPPort=465                          ; GMAIL port used for sending the mail
;~ $ssl=1                               ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

;##################################
; Script
;##################################
$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
If @error Then
    MsgBox(0, "Error sending message", "Error code:" & @error & "  Description:" & $rc)
Else
    MsgBox(0, "Message send", "to " & $ToAddress)
EndIf
and here the include-File: _INetSmtpMailCom.au3
Link to comment
Share on other sites

Try "-1" for option $s_first:

$Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @ComputerName, "-1", 0)

As per:

Func _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_helo = "", $s_first=" ", $b_trace = 0)

Our Exchange server NEEDS the -1 option otherwise a " " (space) is send which returns a 500 instead of a 220. (Had to debug Inet.au3 to get to the bottom of this...)

Link to comment
Share on other sites

  • 6 years later...

Hi AutoBert,

Your e-mail code is much better than the iNet option included with AutoIt.  Yours supports file attachments and HTML e-mail, both of which are lacking in the built in function.  I don't know who to ask to get your _InetSMTPMail object in to the main program, but you've got my vote. 

Thanks,
Christian Blackburn

Christian Blackburn, A+, Network+
 

Link to comment
Share on other sites

6 minutes ago, Christian Blackburn said:

Hi AutoBert,

Your e-mail code is much better than the iNet option included with AutoIt.  Yours supports file attachments and HTML e-mail, both of which are lacking in the built in function.  I don't know who to ask to get your _InetSMTPMail object in to the main program, but you've got my vote. 

Thanks,
Christian Blackburn

There are a few around here. One of the original that supports attachments was Jos' 

 

and later mLipok created an updated version

Maybe these will be useful to you too.

UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Link to comment
Share on other sites

  • Developers

The posted code in this thread is based on my version, like Mlipok's version is. ;)
I have no issue when somebody transfers that UDF into a version in the standard INET UDF, but am not 100% sure whether MS will keep on supporting that COM version it uses.

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

Hi Jos,

There's no telling how long anything will be supported by Microsoft.  Since it works and works better than what we have now I see no issue.  Also isn't INET a COM object as well?  I suppose there could be a Win32API version, but I know I had an INET object in VB6 as well. 

Cheers,
Christian

Christian Blackburn, A+, Network+
 

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...