Link to home
Start Free TrialLog in
Avatar of JimmyDeuce
JimmyDeuceFlag for United States of America

asked on

Send an e-mail via VBScript

I am a .Net programmer so I am struggling with this one. For testing purposes of a larger project I am trying to send an email when an html page loads. Later i will add reports to go out as an attachment. I keep on getting an ActiveX error. Can someone explain to me why this won't work and how I can get it to work on my local machine? Eventually it will go on a server as a scheduled task.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Untitled Page</title>
<script type="text/vbscript">
function sendEmail()
      Set objMailer = CreateObject("SMTPsvg.Mailer")
      'Email File
      objMailer.AddRecipient "JimmyDeuce" , "Jimmydeuce@notimportant.com"
      objMailer.AddBcc "Jimbo" , "Jimbo@notimportant.com"
      objMailer.FromName = "Kiosk Report"
      objMailer.FromAddress = "me@somewhere.com"
      objMailer.RemoteHost = "localhost"
      objMailer.ReturnReceipt = false
      objMailer.ConfirmRead = false
      objMailer.Subject = "Subject Here"
      objMailer.BodyText = "Hello World"
      objMailer.ClearAttachments
      objMailer.SendMail            
      Set objMailer = Nothing      
      window.setTimeout "exitApp()",3000       
end function
    </script>
</head>
<body onload="sendEmail()">

</body>
</html>
Avatar of jcott28
jcott28

Do you have the smtp  service setup on the workstation?

You've got to specify a smart host or an smtp server.
Avatar of JimmyDeuce

ASKER

I belive so. I have Outlook installed.
If you setup a smart host on your local machine, you can try this method too:

Set objMailer = CreateObject("CDO.Message")
objMailer.To = "Jimmydeuce@notimportant.com"
objMailer.From = "me@somewhere.com"
objMailer.Subject = "Subject Here"
objMailer.Textbody = "Hello World"
objMailer.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMailer.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
        "127.0.0.1"
objMailer.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMailer.Configuration.Fields.Update
objMailer.Send
i thought localhost was teh smart host in this case.
Outlook is not an smtp service.

Check this out:

http://msdn.microsoft.com/en-us/library/8b83ac7t.aspx
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial