Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbscript sending email

Status
Not open for further replies.

kaul1jos

Technical User
Jan 5, 2001
76
NL
Hi,

I would like to send an email by vbscript to an exchange server in an internal network.
On the workstation where this script should be run is no outlook(express) or other email client.

Who can help me we such a clientside vbscript?

Thanks in advance
 
There are example VBS scripts to send to an SMTP server, but ive ditched them due to inreliabilty.

you could use 3rd party tools with a batch file, such as 'SendMail' (google it)

or i had a thought whilst reading your post, which i might try later. you can send to most SMTP servers totally manually, with no script using a telnet session in the following order

telnet smtp.server.co.uk
helo mail.mailserver.co.uk
mail from: administrator@mailserver.co.uk
rcpt to: support@bloggs.co.uk
data
subject: this is a test from Monkey
Hi
this is a test on behalf of albert
Gurner
.
quit

--------

I'm wondering if it could be scripted? i know a batch script won't work as it identifies it as a spam attempt.

It might have to be a send keys script to put the above commands into a telnet session?

Gurner

 
Hello Kaul1jos,

Try this:
' Begin Code -------------------------------------------------
Dim oName, ODomain, oMyIP, oTo, Attach

' Set "To:" names.
T1 = "Someone@somedomain.com"
T2 = "SomeoneElse@somedomain.com"
Subject = "Email Test " & now
Body = "**********************************************************************************************" & vbCrlf & _
"**************************************Administrator Test************************************** "& vbCrlf & _
"**********************************************************************************************" & vbCrlf & _
"This is an automated message."

' Set the From name
oName = "EmailTester"

' Company Internet Domain Name
ODomain = "YourDomainHere.com"
' Set the SMTP server IP
oMyIP = "Your.SMTP.Server.Here"
' Where do you want the message to be delivered
oTo = T1 &"; "& T2


' Set the visual basic constants as they do not exist within VBScript.
' Do not set your smtp server information here.
Const cdoSendUsingMethod = " _
cdoSendUsingPort = 2, _
cdoSMTPServer = "
'// Create the CDO connections.
Dim iMsg, iConf, Flds
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields

'// SMTP server configuration.
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort

'// Set the SMTP server address here.
.Item(cdoSMTPServer) = oMyIP
.Update
End With

'// Set the message properties.
With iMsg
Set .Configuration = iConf
.To = oTo
.From = oName
.Subject = Subject
.TextBody = Body
End With

'// Add attachments
'Set Logfldr = Ofso.GetFolder(LogDir)

'For Each File In Logfldr.files

' Attach = File.name
' iMsg.AddAttachment LogDir &"\"& Attach

'Next

'Send the message.
iMsg.Send

' End Code -------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top