Last Updated on November 16, 2011 by CSch
You can use MS Windows' VBScript to write a script that is able to log into a remote mail server such as googlemail or any other with your account data and send mails from that server. This can be used to retrieve logs via attachments or to just automate mail processes. The bare script to send a mail looks as follows (the apostrophe after a line signals a comment to the lines content, it does not belong to the script. The data all go inside the doublequotes if there are any):
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Type in the mail's subject here"
objMessage.From = " <the sender mail goes here, you need the login data for it>"
'The mail address goes inside the tags
objMessage.To = "the receiver mail goes here"
objMessage.TextBody = "Here goes the actual mail message"
objMessage.Addattachment "Fill in the complete path to your attachment, otherwise leave complete line"
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'determines whether you use local smtp (1) or network (2)
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "Fill in your smtp (outgoing) server"
'You can find your provider's server address somewhere on the homepage or by googling for smtp server lists
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
'Determines the authentication mode. 0 for none, 1 for basic (clear text), 2 for NTLM
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "should be the same as the sender mail - login data for your server"
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "your email's password - login data for your server"
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'This is the default port used by most servers. Find out if yours is using a different one if there are problems
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
'Use SSL? True or False
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
'Maximum time connection is tried to be established
It is recommended not to use this script on a computer you are not the only user of, since your email and its password are openly visible. However you can just create a new one for that purpose. You can easily embed this script into any other VBScript, schedule it or do whatever you want with it.