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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending e-mail using vbscript

Status
Not open for further replies.

collierd

MIS
Dec 19, 2001
509
DE
Hello

How do I send e-mail using vbsript
I just want to send a message dependant upon certain criteria
I have tried using CreateObject(CDO.Message) this just returns an error (Active X component can't create object: 'CDO.Message')
Is this a windows NT issue
Is there another type of oject I can create and does anybody have any instructions/web address for this

Thanks

Damian.
 
you need to be doing this via server side (ASP) coding. try using CDONTS or JMAIL to send the email also. There are plenty of simple examl=ples online to help you out. I dare to learn more
admin@onpntwebdesigns.com
 
Hey man,

Try this function out, it's not my code and I don't remember where I found it. catch 22, you have to have smtp services installed, it comes with IIS 5.

Ciao,

Brian

Function send_email (strTo, strSubject, strBody)
Dim strFrom
Dim myCDONTSMail

' Create the CDONTS NewMail object
Set myCDONTSMail = CreateObject("CDONTS.NewMail")

' Set the Reply-To header of the Newmail object:
'myCDONTSMail.Value("Reply-To") = strReply_To

' Send the message and cleanup CDONTS objects
myCDONTSMail.Send "soetech@pitt.edu", strTo, strSubject, strBody
'Set myCDONTSMail = Nothing


End Function
 
If outlook is installed,

'Send Outlook Mail Item w/Attachment - can be called from batch with arguments
' ***************************************************

Dim objOutlook
Dim objNameSpace

Dim mItem

Dim strReceipient
Dim strSubject
Dim strBodyText
Dim strMsg


Dim pAttachment
Dim strAttach
set collargs = wscript.arguments

Const olMailItem = 0

strReceipent = collargs(0)
strsubject = collargs(1)
strBodyText = collargs(2)

strAttach= InputBox("Enter path to attachment.", "Attachment:")

Set objOutlook = CreateObject("Outlook.application")
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set mItem = objOutlook.CreateItem(olMailItem)


mItem.To = strReceipent
mItem.Subject = strSubject
mItem.Body = strBodyText

If Len(strAttach) > 0 Then
Set pAttachments = mItem.Attachments
pAttachments.Add strAttach
End If

mItem.Save
mItem.Send



If strReceipent = "" Then
Msgbox "No Receipient provided. Mail not sent", vbInformation,"Mail Error"
End If



' **** Clean up
'
Set mItem = Nothing
Set objNameSpace = Nothing
set objOutlook = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top