Sign in to follow this  
Followers 0
mein

Automating emails

4 posts in this topic

I have a need to automate the sending of documents to different addresses.

The files will be created and kept in a single folder and then need to be sent to specific addresses depending on the name of the file.

Is this something that can be done with autoit so that when I run a script it checks the folder then creates and sends the email?

Any help would be appreciated.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Look here

EDIT:

here is my own simplified version (without error handling)

Func _SendEmail($e_From, $e_To, $e_Subject, $e_Text, $e_attach = '')
    $objMessage = ObjCreate ("CDO.Message")
    If @error Then Return
    $objMessage.BodyPart.ContentTransferEncoding = "8bit"
    $objMessage.BodyPart.CharSet = "windows-1250"
    $objMessage.From = $e_From
    $objMessage.To = $e_To
    $objMessage.Subject = $e_Subject
    $objMessage.TextBody = $e_Text
    If $e_attach <> '' Then $objMessage.AddAttachment($e_attach) ; @ScriptDir & "\Test.txt"
    $objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $ini_smtp_server
    $objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $ini_smtp_port
    $objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    $objMessage.Configuration.Fields.Update
    $objMessage.Send
    $objMessage = 0
EndFunc
Edited by Zedna

Share this post


Link to post
Share on other sites

Look here

EDIT:

here is my own simplified version (without error handling)

Func _SendEmail($e_From, $e_To, $e_Subject, $e_Text, $e_attach = '')
    $objMessage = ObjCreate ("CDO.Message")
    If @error Then Return
    $objMessage.BodyPart.ContentTransferEncoding = "8bit"
    $objMessage.BodyPart.CharSet = "windows-1250"
    $objMessage.From = $e_From
    $objMessage.To = $e_To
    $objMessage.Subject = $e_Subject
    $objMessage.TextBody = $e_Text
    If $e_attach <> '' Then $objMessage.AddAttachment($e_attach) ; @ScriptDir & "\Test.txt"
    $objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $ini_smtp_server
    $objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $ini_smtp_port
    $objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    $objMessage.Configuration.Fields.Update
    $objMessage.Send
    $objMessage = 0
EndFunc

Can i use this script by using username and password ?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Can i use this script by using username and password ?

No problem, look at link I posted above. JdeB's function has more options. My script is simplified as I said.

;Authenticated SMTP
    If $s_Username <> "" Then
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
    EndIf
Edited by Zedna

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