Jump to content

Trying to send email - failing


Recommended Posts

Hi all,

 

Trying to test sending an email using the _INetSmtpMail function, but I cannot get it to work.

 

#include <Inet.au3>
#include <MsgBoxConstants.au3>

Local $s_SmtpServer = "smtp.gmail.com"
Local $s_FromName = "My Name"
Local $s_FromAddress = "x@gmail.com"
Local $s_ToAddress = "x@gmail.com"
Local $s_Subject = "Test - subject line"
Local $as_Body[2]
$as_Body[0] = "Test"
$as_Body[1] = "End of test"
Local $iResponse = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body)
Local $iErr = @error
If $iResponse = 1 Then
    MsgBox($MB_SYSTEMMODAL, "Success!", "Mail sent")
Else
    MsgBox($MB_SYSTEMMODAL, "Error!", "Mail failed with error code " & $iErr)
EndIf

 

"Mail failed with error code 50" is the message I receive.  I've looked at what the autoit help page says: 50x - Cannot send body. x indicates the line number of $aBody (first line is 0). 

I cannot find any solution online that has fixed this issue.  Any guidance would be much appreciated!

 

Link to comment
Share on other sites

  • Developers

That is because that UDF ONLY send to standard SMTP servers, not secure servers like Google!
Look for _InetSmtpMailCom() in the examples forum which does handle this.

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

×
×
  • Create New...