Can anyone show me some code on how to email using vbscirpt?
Thank you.
Printable View
Can anyone show me some code on how to email using vbscirpt?
Thank you.
This works on IIS 4/5 so long as you have the CDONTS.NewMail object working.Code:Set objMailer = Server.CreateObject("CDONTS.Newmail") ' Reference the Mailer object variable to an instance of "CDONTS.Newmail"
objMailer.To = "[email protected]" 'Fillin the to email address...
objMailer.From = "[email protected]" ' ...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
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]
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:
I canne explain that object model...just copied it outta MSDN. :DCode:Session
Folder (Inbox or Outbox)
Messages collection
Message
AddressEntry
Attachments collection
Attachment
Recipients collection
Recipient
NewMail
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