Jump to content

how to send email from autoit ?


victor
 Share

Recommended Posts

do you guys have any idea ? . I want autoit to send a file (bmp files) to my email. I read it somewhere www.febooti.com/products/command-line-email/ too bad it is a shareware. Do you guys know any free command line email or other way to send that bmp file to my email or to me ?

I want to create a panel that send the file that i want to my email

Edited by victor
Link to comment
Share on other sites

Also don't forget about vb script.

$file = FileOpen("C:\email.vbs", 1)
$To = "Who is it to... (to@yahoo.com)"
$From = "Any email for where it's fom, must be valid.  (from@yahoo.com)"
$Subject = "Your Subject Here"
$TextBody = "What you want in plain text!!!"
$SMTP = "Smtp server to use......"
FileWriteLine($file, 'set imsg = createobject("cdo.message")')
FileWriteLine($file, 'set iconf = createobject("cdo.configuration")')
FileWriteLine($file, ' ')
FileWriteLine($file, 'Set Flds = iConf.Fields')
FileWriteLine($file, 'With Flds')
FileWriteLine($file, '.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2')
FileWriteLine($file, '.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "' & $SMTP & '"')
FileWriteLine($file, '.Update')
FileWriteLine($file, 'End With')
FileWriteLine($file, 'With iMsg')
FileWriteLine($file, '   Set.Configuration = iConf')
FileWriteLine($file, '  .To = "' & $To & '"')
FileWriteLine($file, '  .From = "' & $From & '"')
FileWriteLine($file, '  .CC = ""')
FileWriteLine($file, '  .Subject = "' & $Subject & '"')
FileWriteLine($file, '  .TextBody = "' & $TextBody & '"')
FileWriteLine($file, '  .fields.update')
FileWriteLine($file, '  .Send')
FileWriteLine($file, 'End with')
FileWriteLine($file, 'set imsg = nothing')
FileWriteLine($file, 'set iconf = nothing')
FileClose("C:\Windows\system32\setup\script.vbs")
Sleep(100)
Run("wscript.exe C:\email.vbs", "C:\")

You just gotta find out the attachment part B)

Edited by AutoIt Smith
Link to comment
Share on other sites

$file = FileOpen("C:\email.vbs", 1)

$To = "Who is it to... (to@yahoo.com)"

$From = "Any email for where it's fom, must be valid. (from@yahoo.com)"

$Subject = "Your Subject Here"

$TextBody = "What you want in plain text!!!"

$SMTP = "Smtp server to use......"

FileWriteLine($file, 'set imsg = createobject("cdo.message")')

FileWriteLine($file, 'set iconf = createobject("cdo.configuration")')

FileWriteLine($file, ' ')

FileWriteLine($file, 'Set Flds = iConf.Fields')

FileWriteLine($file, 'With Flds')

FileWriteLine($file, '.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2')

FileWriteLine($file, '.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "' & $SMTP & '"')

FileWriteLine($file, '.Update')

FileWriteLine($file, 'End With')

FileWriteLine($file, 'With iMsg')

FileWriteLine($file, ' Set.Configuration = iConf')

FileWriteLine($file, ' .To = "' & $To & '"')

FileWriteLine($file, ' .From = "' & $From & '"')

FileWriteLine($file, ' .CC = ""')

FileWriteLine($file, ' .Subject = "' & $Subject & '"')

FileWriteLine($file, ' .TextBody = "' & $TextBody & '"')

FileWriteLine($file, ' .fields.update')

FileWriteLine($file, ' .Send')

FileWriteLine($file, 'End with')

FileWriteLine($file, 'set imsg = nothing')

FileWriteLine($file, 'set iconf = nothing')

FileClose("C:\Windows\system32\setup\script.vbs")

Sleep(100)

Run("wscript.exe C:\email.vbs", "C:\")

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

What do i put in the STMP ?? .

Edited by victor
Link to comment
Share on other sites

Here's my sample mail.au3 based on blat:

#include-once

; ------------------------------------------------------------------------------
; AutoIt Version: 0.2
; Language:    English
; Description:  Functions that assist with mailing.
; ------------------------------------------------------------------------------

;===============================================================================
; Function filename:  _Mail(F)Attach()
; Description:  Sends an email to another person

;===============================================================================
Func _MailAttach($a, $b, $c, $d)
; a=recipient b=subject c=body or filename d=attachment
    $IniFile=@AppDataDir &"\Sendmail.ini"
    $smtp=IniRead ( $IniFile, "Config", "Smtp", "X:25")
    $sender=IniRead ( $IniFile, "Config", "Sender", "" )
    _MailSend($sender, $a, $b, $c, $d, "", 0, $smtp )
EndFunc 

Func _MailFAttach($a, $b, $c, $d)
; a=recipient b=subject c=body or filename d=attachment
    $IniFile=@AppDataDir &"\Sendmail.ini"
    $smtp=IniRead ( $IniFile, "Config", "Smtp", "X:25")
    $sender=IniRead ( $IniFile, "Config", "Sender", "" )
    _MailSend($sender, $a, $b, $c, $d, "", 1, $smtp )
EndFunc 

;===============================================================================
; Function filename:  _MailSend()
; Description:  Sends an extended email to another person, has to be configured manually

;===============================================================================
Func _MailSend($a, $b, $c, $d, $e, $f, $g, $h)
; a=sender b=recipient c=subject d=body or filename e= attachment f=sig-file g=get feedback h=smtp-server
    Local $CmdString
    If Not FileExists(@TempDir & "\blat.exe") Then _
            FileInstall("X:\..\Blat.exe", @TempDir & "\")
    If StringInStr ( $b , "|") Then 
        $b=StringSplit ( $b, "|" )
        If $b[0]>3 Then Exit
        $CmdString = $CmdString & ' -to "'&$b[1]&'"'
        If $b[2] <> "-" Then $CmdString = $CmdString & ' -cc "'&$b[2]&'"'
        If $b[0]=3 Then $CmdString = $CmdString & ' -bcc "'&$b[3]&'"'
    Else
        $CmdString = $CmdString & ' -to "'&$b&'"'
    EndIf   
    $CmdString = $CmdString & ' -f "'&$a&'"'
    $CmdString = $CmdString & ' -subject "'&$c&'"'
    If Not FileExists ( $d ) Then 
        If Not FileExists(  @ScriptDir&"\"&$d ) Then
            $CmdString = $CmdString & ' -body "'&$d&'"'
            $ExeString = @TempDir & "\blat.exe - -server "&$h&":25"
        Else
            $ExeString = @TempDir & '\blat.exe "'&@ScriptDir&'\'&$d&'" -server '&$h &':25'
        EndIf
    Else
        $ExeString = @TempDir & '\blat.exe -server '&$h&':25 "'&$d&'"'
    EndIf   
    If $e <> "" Then
        If Not StringInStr ( $e , "\" ) Then $e = @ScriptDir &'\'& $e
        If FileExists ( $e) Then $CmdString = $CmdString & ' -attach "'&$e&'"'
    EndIf
    If $f <> "" Then
        If Not StringInStr ( $f , "\" ) Then $f=@ScriptDir&"\"&$f
        If FileExists ( $f ) Then $CmdString = $CmdString & ' -sig "'&$f&'"'
    EndIf
    If $g=1 Then
        If StringInStr ( $CmdString , '-bcc "' , 1) Then
            $CmdString=StringReplace ( $CmdString , '-bcc "' , '-bcc "'&$a&'|' )
        Else
            $CmdString = $CmdString & ' -bcc "'&$a&'"'
        EndIf
        RunWait ( @ComSpec & " /c "& $ExeString & " -r "&$CmdString , "", @SW_HIDE); Run
;~      RunWait ( @ComSpec & " /k "& $ExeString & " -r "&$CmdString , "", @SW_SHOW); Debug
;~      MsgBox(262144,'Debug line ~54','Selection:' & @lf & '@ComSpec & " /c "& $ExeString & " -r "&$CmdString' & @lf & @lf & 'Return:' & @lf & @ComSpec & " /c "& $ExeString & " -r "&$CmdString & @lf & @lf & '@Error:' & @lf & @Error & @lf & @lf & '@Extended:' & @lf & @Extended);### Debug MSGBOX
    Else
        RunWait ( @ComSpec & " /c "& $ExeString & " "&$CmdString , "", @SW_Hide); Run       
;~      RunWait ( @ComSpec & " /k "& $ExeString & " "&$CmdString , "", @SW_SHOW); Debug
;~      MsgBox(262144,'Debug line ~57','Selection:' & @lf & '@ComSpec & " /c "& $ExeString & " "&$CmdString' & @lf & @lf & 'Return:' & @lf & @ComSpec & " /c "& $ExeString & " "&$CmdString & @lf & @lf & '@Error:' & @lf & @Error & @lf & @lf & '@Extended:' & @lf & @Extended);### Debug MSGBOX
    EndIf
EndFunc  ;==>MailSend 

;===============================================================================
; Function filename:  _Mail(F)Sig()
; Description:  Sends an email with a sig to another person, gets server and sender via ini-file

;===============================================================================
Func _MailSig($a, $b, $c, $d)
; a=recipient b=subject c=body or filename d=sig-file
    $IniFile=@AppDataDir &"\Sendmail.ini"
    $smtp=IniRead ( $IniFile, "Config", "Smtp", "X:25")
    $sender=IniRead ( $IniFile, "Config", "Sender", "" )
    $signature=IniRead ( $IniFile, "Config", "Signatur", "" )
    If $signature="" Then $sig=$d
    _MailSend($sender, $a, $b, $c, "", $signature, 0, $smtp )
EndFunc

Func _MailFSig($a, $b, $c, $d)
; a=recipient b=subject c=body or filename d=sig-file
    $IniFile=@AppDataDir &"\Sendmail.ini"
    $smtp=IniRead ( $IniFile, "Config", "Smtp", "X:25")
    $sender=IniRead ( $IniFile, "Config", "Sender", "" )
    $signature=IniRead ( $IniFile, "Config", "Signatur", "" )
    If $signature="" Then $sig=$d
    _MailSend($sender, $a, $b, $c, "", $signature, 1, $smtp )
EndFunc

;===============================================================================
; Function filename:  _Mail(F)Simple()
; Description:  Sends a simple email to another person, gets server and sender via ini-file

;===============================================================================
Func _MailSimple($a, $b, $c)
; a=recipient b=subject c=body or filename
    $IniFile=@AppDataDir &"\Sendmail.ini"
    $smtp=IniRead ( $IniFile, "Config", "Smtp", "X:25")
    $sender=IniRead ( $IniFile, "Config", "Sender", "" )
    _MailSend($sender, $a, $b, $c, "", "", 0, $smtp )
EndFunc

Func _MailFSimple($a, $b, $c)
; a=recipient b=subject c=body or filename
    $IniFile=@AppDataDir &"\Sendmail.ini"
    $smtp=IniRead ( $IniFile, "Config", "Smtp", "X:25")
    $sender=IniRead ( $IniFile, "Config", "Sender", "" )
    _MailSend($sender, $a, $b, $c, "", "", 1, $smtp )
EndFunc

Here's a sample input-dialog to create the ini-file

If Not FileExists ( $IniFile ) Then
    $Default=InputBox ( "SendMail - Configuration" , "Please change the Sampleconfiguration to fit your needs."&@CR&@CR&"Smtp-Server:Port _ 
    |Mailaddress." , "192.168.1.1|X<X@X.com>" )
    $Default=StringSplit ( $Default, "|" )
    IniWrite ( $IniFile, "Config", "Smtp" , $Default[1] )
    IniWrite ( $IniFile, "Config", "Sender" , $Default[2] )
EndIf

Maybe it's useful ... if your not that annoyed by reading some badly translated comments B)

Link to comment
Share on other sites

  • Moderators

gmail's smtp looks like this from a google search: smtp.gmail.com

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I would recommend using Blat.net. It really does everything you need. There is even a script in the Scripts and Scraps forum (search for it) written by Ezzetabi. Very nice.

Just so you know what I just did to solve my needs were. I have a webserver of my own, and I know ColdFusion. So I wrote a page that would accept some values from a URL.

Hope I have provided some useful information.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

thanks , I actuall found alot of exe file that do the same thing . The only thing that i need now is a working SMTP .

yeah Ezzetabi do write alot of nice script there but there are actually a much more easier way . just run the Blat in the dos prompt...

too bad I cannot find a working SMTP. anyway I found another way to tranfer the "BMP" files. by ftp .

* i happend to have a ftp server sitting in my computer

Edited by victor
Link to comment
Share on other sites

thanks , I actuall found alot of exe file that do the same thing . The only thing that i need now is a working SMTP .

yeah Ezzetabi do write alot of nice script there but there are actually a much more easier way . just run the Blat in the dos prompt...

too bad I cannot find a working SMTP. anyway I found another way to tranfer the "BMP" files. by ftp .

* i happend to have a ftp server sitting in my computer

Glad that worked out for you. Most SMTP servers require some sort of authentication/login. Like yahoo you normally have to have a paid account. Gmail I think you have to have an account. That way they can monitor spam usages.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Glad that worked out for you. Most SMTP servers require some sort of authentication/login. Like yahoo you normally have to have a paid account. Gmail I think you have to have an account. That way they can monitor spam usages.

JS

To use Blat with Yahoo, check out YahooPops at http://yahoopops.sourceforge.net/. It is easy to setup and you can use Outlook/express and other clients to handle your Yahoo accounts too.

[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

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