Results 1 to 5 of 5

Thread: Email in vbscript

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    240

    Smile

    Can anyone show me some code on how to email using vbscirpt?
    Thank you.





  2. #2
    Guest
    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
    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]

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    240

    Smile Thanks alot

    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.

  4. #4
    Guest
    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:

    Code:
    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.


  5. #5
    Addicted Member Mage33's Avatar
    Join Date
    Aug 2000
    Location
    Petaluma, California
    Posts
    138

    Smile Heh

    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
    Stephen Haney- 115 116 101 118 101 31 72 65 78 69 89
    -ShardsOfSilence.net- ^ My name in ASCII ^
    You forget something new every day
    | WinME | VB6 Pro | MSC++ | Lambda MOO |

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width