Using VBScript to send email from Gmail
Windows only
Windows only
I do not usually write scripts and batch files that I use , but I wanted to share this script because I use it all the time. VBScript files are good, because usually they are simply encoded and work across virtually all Windows-powered machines. Just drop the code in the file. VBS, and from there it can be done in batch files very easily.
contents of the file below, and once created, you can send email using your Gmail account directly from the command line. In the code there are two things that need to be set up: e-mail address and password of the account you want to send as. While performing the VBScript file, it should be just three parameters: e-mail address, subject and message body. This is an optional fourth parameter, which accepts that is the path to the file to the file you want to attach to an e-mail. Thats all.
I use this all the time? You can easily call this file from other scripts or batch files so that it sends me a notification when something ends. Sometimes I use it only to have a nice history, when some of my batch files a complete(or to check whether or not conducted), but another time it will insert a dynamic text in the message. For example, if an error occurs it may have put the error message in the email. An alternative to this would be to attach the log file using the optional fourth parameter.
The advantage of this method is that the script can send emails without setting up an SMTP server on your computer. Of course it will not be able to send e-mails of mass volume of Google is limited to approximately 500 messages sent per day, but it should be more than adequate for personal purposes.
Lets look at the code that looks like
Code starts here:
"Usage: cscript sendemail.vbs "
" Ex. Not included: cscript sendemail.vbs example@gmail.com "test subject" the body of an email test "
" Ex. W / include: cscript sendemail.vbs example@gmail.com "test subject" test email body "," c: scripts log.txt "
********* **
**** CONFIGURATION The e-mail address and password
fromEmail Const = "email_sender@gmail.com"
Const password = "password "
**** END CONFIGURATION
***********
Dim emailObj, emailConfig
Set emailObj = CreateObject("CDO.Message")
= emailObj.From fromEmail
= emailObj.To Wscript.Arguments.Item(0)
emailObj.Subject = Wscript.Arguments.Item(1)
= emailObj.TextBody Wscript.Arguments.Item(2)
If WScript.Arguments.Count> 3 Then
emailObj.AddAttachment Wscript.Arguments.Item(3)
End If
emailConfig Set
emailConfig.Fields(http://schemas .microsoft.com / cdo / configuration / smtpserver ") =" smtp.gmail.com "
emailConfig.Fields(http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
emailConfig.Fields(http://schemas.microsoft.com/cdo/configuration/sendusing ") = 2
emailConfig.Fields(http://schemas.microsoft.com / cdo / configuration / SMTPAuthenticate ") = 1
emailConfig.Fields(http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
emailConfig.Fields( "http://schemas.microsoft.com/cdo/configuration/sendusername") =
emailConfig.Fields(http://schemas.microsoft.com/cdo/configuration/sendpassword ") = password
emailConfig.Fields.Update
emailObj.Send
Set emailobj
= nothing Set emailConfig
This is the end of the code( Download the script ) ^
You can see it starts from the use of an example of how you can call the VBScript file. Given the nature of the exercise files or VBScript can not include the cscript part, but in general you are always better here is not to ensure that it will be on your right. Heres an example of how this looks like it is done from the command line:
Note: sendemail.vbs file is located in the root directory of drive C, when it ran.
Armed with this script you should be able to take it and throw it in a batch file or call it from anywhere that you can take things from the command line. One of the things we consider is to create additional e-mail account only to send those messages. Not only that keep your Sent clean the primary Gmail account, but will also be a bit more secure because the password for the senders account is stored in plaintext in the script.
Here is a nicely formatted version of VBScript in advance, which can be downloaded, and all ready to go for you(after completing the two e-mail address and password in a script file, of course):
Download the zipped copy of the VBScript
Via:
Using VBScript to send email from GmailRelated Posting Search Result:
Bulk Open Links in Firefoxwhile back we wrote about the cool called Snap Links , which allow you to draw a box around a hyperlink with y...
Screenshot, ruler, Magnifier, Color Picker and all in one application!Windows; Mac Last week we wrote about some of the a great ruler for Windows and Mac , but it looks lik...CyberNotes: Thottle or throttling in Firefox and Internet Explorer
Wednesday browser Windows only Have you ever wanted to have more control over how the browser,...MyPaint: Open Source Software Digital Painting
(click to enlarge) windows; Linux I have never ve much an artist, but it does not, AOT, this...Live Bookmarks in the sidebar of Firefox
Live Bookmarks is a feature that is included in Firefox for ages, and created a simple way to subscribe to t...Storing files on the iPhone from the App Free for 2-weeks only
One thing that really sucks with the iPhone and iPod Touch is that none of them can not be used to store files...
Using VBScript to send email from Gmail
By: blue27
Video Email - The Future Of Communication Daily Bible Verse: Emails with Heart The 3 Things To Avoid When Emailing Your List How To Recover Lost E-mail Clients Password Creating Email Newsletters The Right Way How To Avail Of A Mailing Envelope Better Use of Emails in Lead Generation Why Profane Emails From Atrazine Scientist Tyrone Hayes Are Important Making the right mailbox choice Gmail Looks To Clear Clutter With Priority Inbox Email People Search Can Find Others Fast Email People Search Can Find Others Email Addresses Fast Email People Search Finding People With Email Address Finders