Click to See Complete Forum and Search --> : Email in vbscript
Sophtware
Aug 7th, 2000, 02:44 AM
Can anyone show me some code on how to email using vbscirpt?
Thank you.
Set objMailer = Server.CreateObject("CDONTS.Newmail") ' Reference the Mailer object variable to an instance of "CDONTS.Newmail"
objMailer.To = "webmaster@mralston.co.uk" 'Fillin the to email address...
objMailer.From = "matthew@ralston.net" ' ...the from email address...
objMailer.Subject = "Email Subject" ' ...the subject...
objMailer.BodyFormat = 0 '... and prepair to send it as
objMailer.MailFormat = 0 ' HTML formatted email
objMailer.Body = "Sample email message." 'The message to send
'Send the email and dismiss the mailer object
objMailer.Send
Set objMailer = Nothing
This works on IIS 4/5 so long as you have the CDONTS.NewMail object working.
If you want to send HTML mail, set the BodyFormat and MailFormat to 0. Otherwise I think you set them to 1...not quite sure as I never send plain text emails. :)
[Edited by matthewralston on 08-07-2000 at 04:54 AM]
Sophtware
Aug 7th, 2000, 02:44 PM
I understand the code but the only question i have is reference the mailer object variable to a instance of ("CDONTS.newmail") <----------- what is "CDONTS.newmail"
haha Now i dont me too sound retarded or anything but i dont remember seening that refernce in visual basic.
Thanks MatthewR.
You won't see it in straight VB. It's an ActiveX control that comes with IIS for NT. It's basically a mini program that actually sends the email for you.
CDONTS actually stands for Collaboration Data Objects for NT Server, and has the following sub components:
Session
Folder (Inbox or Outbox)
Messages collection
Message
AddressEntry
Attachments collection
Attachment
Recipients collection
Recipient
NewMail
I canne explain that object model...just copied it outta MSDN. :D
Mage33
Aug 9th, 2000, 07:15 PM
Another way of doing it is something like this:
(This will allow you to CC as well as a few other things)
(Make a function named MailThis)
Function MailThis(strSubject, strBody)
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromName = Session("Who sends it's Name")
Mailer.FromAddress= Session("Who sends it's Addy")
Mailer.RemoteHost = "The Mail server"
Mailer.AddRecipient "Recipient's Name","Recipient's E-Mail"
(Take this next line out if unneeded)
Mailer.AddCC "CC's Name","CC's E-Mail"
Mailer.Subject = strSubject
Mailer.BodyText = strBody
End Function
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.