Sign in to follow this  
Followers 0
jlandes

Smtpsend

17 posts in this topic

Since AutoIt is a language designed to automate tasks in Windows, it is sometimes used as a means to schedule processes to run. I know that I have found a need on multiple occasions to send e-mail from a script that gives information about the scripts execution, much like a log file. It would be beneficial to everyone, I think, if there were an internal command that could be used to send an e-mail message using the SMTP protocol. A function that has syntax similar to this would be sufficient for accomplishing this task:

MailSend ( "SMTP Host", "From Address", "To Addresses", "Subject", "Message Body" )

What does everyone think? I don't think we need to worry about the ability to include an attachment, although it would be nice. In addition, I don't even care if it supports sending HTML e-mails, just as long as I can send an e-mail from within a script without having to use something like Blat to do so. Is this something that can be done?


Sincerely yours,Jeremy Landesjlandes@landeserve.com

Share this post


Link to post
Share on other sites



RunMail3 is great for scripting since it has a built in SMTP server. It's freeware, but i think it's no longer being developed.

Share this post


Link to post
Share on other sites

Jon, virus scanner attacks also program that do not have a SMTP server included?

jlandes seems not interested about this...

Blat is an other mail sender.

http://www.interlog.com/~tcharron/blat.html

Share this post


Link to post
Share on other sites

Newer blat version on SourceForge.

Share this post


Link to post
Share on other sites

I've wanted for ages a way for a script to send an e-mail. Using a command line tool would be fine, but I can't find anything to work within an Exchange set-up (ie, using MAPI to send the e-mail I guess).

Share this post


Link to post
Share on other sites

RunMail3 is great for scripting since it has a built in SMTP server. It's freeware, but i think it's no longer being developed.

Why do you have to install a command line tool? Seems dodgy to me!

Share this post


Link to post
Share on other sites

I use a lot of command line tools. I like AutoIt's small size and ability to do almost anything I need. The fact that I can add in SMTP or almost any other thing I need is a great feature.

I have used BLAT many times in my AutoIt scripts, as well as a few dozen command line tools. The nice part is that I only need to add the additional size when I have a need for it.

But I am not the one who puts AutoIt on the scale to wiegh its size. :whistle:


AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

I've wanted for ages a way for a script to send an e-mail. Using a command line tool would be fine, but I can't find anything to work within an Exchange set-up (ie, using MAPI to send the e-mail I guess).

If you can get access to either the Exchange Resource Kit or BORK (Back Office Resource Kit), look for a tool called MAPISEND.EXE. You might be able to find a copy on the Internet somewhere. Here's an article that describes this utility:

How can I send a mail message from the command line?

Hope this helps. Thx.


Sincerely yours,Jeremy Landesjlandes@landeserve.com

Share this post


Link to post
Share on other sites

If you can get access to either the Exchange Resource Kit or BORK (Back Office Resource Kit), look for a tool called MAPISEND.EXE.

Cool, I'm definately gonna check that out when I get to work.

Thanks

Share this post


Link to post
Share on other sites

Jon,

If you don't want to include an SMTP function, I can understand your reasons. Would it be possible to include a MAPISend function? Some of the newer releases of Outlook prompt the user as to whether they want to continue sending the e-mail or not. I'm just curious. Thx.


Sincerely yours,Jeremy Landesjlandes@landeserve.com

Share this post


Link to post
Share on other sites

I just call a vbs script at the end of auto it so I know it's done.

Run("cscript \\server\sendmail\sendmail.vbs Subject")

--------------------------------------------

sendmail.vbs

Dim strUser

Dim strSubject

ParseCommandLine()

Set WshNetwork = WScript.CreateObject("WScript.Network")

Set WshShell = WScript.CreateObject("WScript.Shell")

Subject = strSubject

User = WshNetwork.UserName

ComputerName = WshNetwork.ComputerName

'Sending a text email using a remote server

User = User & "@something.com"

'wscript.echo User & " " & ComputerName

Call Send(User, ComputerName, Subject)

Sub Send(User, ComputerName, Subject)

Set objMessage = CreateObject("CDO.Message")

objMessage.Subject = Subject

objMessage.From = User

'edit the To

objMessage.To = "me"

'objMessage.TextBody = "Testing Email Service"

objMessage.HTMLBody = "<h1>" & Subject & " Update Done on Computer: " & "<font color='#FF0000'>" & ComputerName & "</font></h1>"

objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server

objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "192.168.10.2"

'Server port (typically 25)

objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

objMessage.Configuration.Fields.Update

objMessage.Send

End Sub

Sub ParseCommandLine()

Dim vArgs

set vArgs = WScript.Arguments

if vArgs.Count <> 1 then

DisplayUsage()

Else

strSubject = vArgs(0)

End if

End Sub

Sub DisplayUsage()

WScript.Echo

WScript.Echo "Usage: cscript.exe " & WScript.ScriptName & " <Subject>"

WScript.Echo "Example: cscript " & WScript.ScriptName & " " & chr(34) & "Subject here" & chr(34)

WScript.Quit(0)

End Sub

Share this post


Link to post
Share on other sites

Some of the newer releases of Outlook prompt the user as to whether they want to continue sending the e-mail or not.

Yeah, and what a bugger it is too! I've tried using Mapisend.exe and I like it, except for the fact that Outlook causes that warning to pop up, and from what I see I can't get round it. Well, not easily anyways.

Share this post


Link to post
Share on other sites

Yeah, and what a bugger it is too! I've tried using Mapisend.exe and I like it, except for the fact that Outlook causes that warning to pop up, and from what I see I can't get round it. Well, not easily anyways.

Here is a means to get around the outlook dialog box...

http://www.contextmagic.com/express-clicky...ree-version.htm

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

No way. Virus scanners are all over files that contain SMTP functions.

Not really. The fact that has a SMTP function will probably don't make it detected. But as soon as the first smart guy start using in in a virus, the antivirus vendors will be forced to detect AutoIT as "dangerous application" or "security private risk". This happened to some ftp servers and remote administration programs.

Also the way it has been requested seems that you want to use some open relay this will definitely look dubious.

If you really need it without relaying on some 3th party tool, I recommend scripting Internet explore to send the email. This shouldn't be so hard, I think some snippets are already availed to sign up to MSN. Just paste the email and click send. :)

Edited by sogard

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