Jump to content

Recommended Posts

Posted

I am using the following code to try to send an email through an autoit script. (I removed the variables for security reasons)

 

#include <Inet.au3>

Local $SmtpServer = ""      
Local $s_FromName = ""
Local $s_FromAddress = ""
Local $s_ToAddress = ""
Local $s_Subject = "My Test UDF"
Local $as_Body[2]
$as_Body[0] = "Testing the new email udf"
$as_Body[1] = "Second Line"
Local $Response = _INetSmtpMail($SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @ComputerName, -1) 
Local $err = @error
If $Response = 1 Then
    MsgBox(0, "Success!", "Mail sent")
Else
    MsgBox(0, "Error!", "Mail failed with error code " & $err)
Endif

I am getting a response that the email was sent successfully but am receiving nothing. Could it be a firewall issue? If so, how would I be able to tell?

  • Developers
Posted (edited)

What about you answer the question I had in the other thread, but do that here, so we use this thread to look at you problem instead of this crossposting questions stuff?

... but this can't be the script you are testing with....right?

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

Posted

Sending to a local SMTP server. I am using this script just to test to see if i can get it to send an email at all. Then I will implement this in to my main script 

Posted (edited)

@greichert

The advice about turning on tracing, in the old post, is still relevant.  It will allow you to see the the conversation with the mail server in order for you to trouble shoot what the issue may be.  The trace flag is the last parameter.  Set it to 1 to enable tracing.  An example is below.

Local $Response = _INetSmtpMail($SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @ComputerName, -1, 1)

Also, by default, SMTP goes over TCP port 25.  Many ISPs, at least here in the U.S. block outbound connections over port 25.  If you have telnet installed, you can verify whether port 25 is getting blocked by trying to telnet to your mail sever, by opening a CMD prompt, and typing in a command like:  "telnet your.mailserver.com 25".  If port 25 is blocked, you can probably connect using port 465 (for plain text) or whatever port your mail server allows.  One last thing, some mail servers require you to authenticate before being able to send mail through the server.  If this is the case with your mail server, then you will need to use a method that allows you to authenticate. 

There are several command line tools for sending email like cmail, swithmail, and blat.  Personally, I created wrapper UDFs for both cmail and SwithMail and both tools work flawlessly for sending email.  Among many other features, these tools allow you to make encrypted connections over SSL/TLS in case you don't want your credentials (and email) flying across the Internet in clear text.  If you are extremely lazy, SwithMail will even create the command line for you.  Personally, I prefer cmail but swithmail is pretty nice too.  For the record, I get nothing from either developer.  I am merely stating my opinion and what works for me.

=======

I just noticed that your topic title says "from Outlook".  If you want to actually send email using Outlook, then you may want to take a look at @water's OutlookEX UDF.  You can find a discussion of the UDF and a download link here: 

 

You can find examples of how to send email using the UDF here:

https://www.autoitscript.com/wiki/OutlookEX_UDF_-_Mail_Item

 

Edited by TheXman
Updated with references to Water's OutlookEX UDF

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
×
×
  • Create New...