Sign in to follow this  
Followers 0
victor

how to send email from autoit ?

18 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



does thunderbird have command line cupport?

have you tried source forge (sf.net)?

does pine or mutt have a window$ port?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

$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

Share this post


Link to post
Share on other sites

As the outgoing smtp server....

Share this post


Link to post
Share on other sites

mail.yahoo.com ????

Share this post


Link to post
Share on other sites

can you give an example of the stmp server

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

tried both no luck

anyone know how to use gmail smtp ?

Edited by victor

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

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


[center]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.[/center]

Share this post


Link to post
Share on other sites

smtp.gmail.com

465

still get error message

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

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

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

It'd be nice to have an SMTP command from within AutoIt.

B)


---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Share this post


Link to post
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...

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