Results 1 to 14 of 14

Thread: How to send Email using VB script?

  1. #1

    Thread Starter
    Registered User Lior's Avatar
    Join Date
    Jan 2000
    Posts
    307

    Question

    Hello...
    Does any1 here know how do I send an Email using the VB script?
    I wanna have also the Email features: Subject, Body, Attachments.

    Any Idea?

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    ASP I know but it won't work with client side scripting and only on IIS.

    Code:
    <%
    
    
    		set objEMail = Server.CreateObject("CDONTS.NewMail")
    		objEMail.To = "[email protected]"
    		objEMail.From = "[email protected]"
    		objEMail.Subject = "Subject text"
    		objEMail.Body = "Body Text"
    		objEMail.Send
    		set objEMail = nothing
    
    %>
    Paul Dwyer
    Network Engineer
    Aussie In Tokyo

    Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)

  3. #3

    Thread Starter
    Registered User Lior's Avatar
    Join Date
    Jan 2000
    Posts
    307

    Unhappy it doesnt work

    It doesnt work.
    Guys, Any other Idea?
    btw, where can I find some information about all of what I can use within the CreateObject method?

  4. #4
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    If you want to send it through Outlook it's easy.

    set myOlApp = CreateObject("Outlook.Application")
    set newMsg = myOlApp.CreateItem(0) 'Zero = Normal Message
    newMsg.body = yourMessage
    newMsg.subject = yourSubject
    newMsg.Attachments.add FilePath
    newMsg.recipients.add yourFriend
    newMsg.send

  5. #5

    Thread Starter
    Registered User Lior's Avatar
    Join Date
    Jan 2000
    Posts
    307

    Question not working...

    Man...
    I tried it and it is not working.
    I Dont know why.
    Lets say I just wanna send an Email to [email protected]
    the subject would be: "Subject" , the body would be: "Body",
    and the attachment would be "c:\test\test.txt"
    Will the following code be OK?

    Code:
    set myOlApp = CreateObject("Outlook.Application") 
    set newMsg = myOlApp.CreateItem(0) 'Zero = Normal Message 
    newMsg.body = "Body"
    newMsg.subject = "Subject" 
    newMsg.Attachments.add ("c:\test\test.txt")
    newMsg.recipients.add ("[email protected]")
    newMsg.send
    This code is not working, why?

  6. #6
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655

    Talking

    You were almost there, try the following:

    set myOlApp = CreateObject("Outlook.Application")
    set newMsg = myOlApp.CreateItem(0) 'Zero = Normal Message
    newMsg.body = "Body"
    newMsg.subject = "Subject"
    newMsg.Attachments.add "c:\test\test.txt"
    newMsg.recipients.add "[email protected]"
    newMsg.send

  7. #7
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    That is the problem, I think. This code is for accessing Outlook not Outlook Express. I'll have to check and see if you can access Outlook Express in a similar manner.

  8. #8

    Thread Starter
    Registered User Lior's Avatar
    Join Date
    Jan 2000
    Posts
    307

    thanks.

    Thanks...
    I searched the whole net and didnt find a code for Outlook Express. I really hope you will.
    I'm waiting for your answer.
    Its really important for me.

  9. #9
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    I looked everywhere I could think of and couldn't find any code for accessing Outlook Express in this manner. Sorry.

  10. #10

    Thread Starter
    Registered User Lior's Avatar
    Join Date
    Jan 2000
    Posts
    307

    Talking Found the problem.

    Man...Thank you very very much!
    I really appriciate your help.
    Now I'm just starting to work with Microsoft Outlook and not with the Outlook Express.
    With the Original Outlook (which is included with the MS Office package), The code really worked.

    Thanks again,
    For Everything.

  11. #11
    Hyperactive Member Zaphod64831's Avatar
    Join Date
    Mar 2000
    Posts
    268
    Hi, I don't know anything about VBScript programming but this code looks like it would be very helpful, can ayone give me the code as it would be inserted into HTML? I know how to change the values and stuff like that, ie the subject, I just don't know how to put it in the HTML code.
    Email: [email protected]

    Home Page: www.olemac.net/~hutch

    I'm bored, VERY bored, and I got bored with my sig. So I changed it to this.

  12. #12
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    You just simply put script tags around it
    <script language="vbscript">
    'Put code here
    </script>

  13. #13
    Hyperactive Member Zaphod64831's Avatar
    Join Date
    Mar 2000
    Posts
    268
    But where do I put the text to be clicked on?
    Email: [email protected]

    Home Page: www.olemac.net/~hutch

    I'm bored, VERY bored, and I got bored with my sig. So I changed it to this.

  14. #14
    Addicted Member
    Join Date
    Feb 2000
    Posts
    224
    Outlook Express does not support the MAPI. Only Outlook that is part of Microsoft Office Does.

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