Solved

Sending email from a VB script

Posted on 2009-04-13
6
261 Views
Last Modified: 2012-05-06
Hi, i used to use a VB script to test mail flow.
I used to use the below script but now I get the error message,
"Line:     7
Char:     2
Error:     ActiveX component can't create object: 'CDONTS.NewMail'
Code:     800A01AD
Source:  Microsoft VBScript runtime error

It is a new computer, XP service pack 3.
Any ideas?

thanks
StrFrom="name@domain.com"

	strto="name@domain.com"

	strbody="Email test"

	strsubject="Email test"

	
 

	Set objCDOMail = CreateObject("CDONTS.NewMail")

	objCDOMail.From = StrFrom

	objCDOMail.To = strTo

	objCDOMail.Subject = strsubject

	objCDOMail.Body = strBody

	objCDOMail.Send

	Set objCDOMail = Nothing

Open in new window

0
Comment
Question by:SteveSext
  • 4
  • 2
6 Comments
 
LVL 4

Expert Comment

by:Enigma2001
ID: 24134655
Hi,

I just use the following for sending mail. Hope it helps

set oMailMessage = CreateObject("CDO.Message")
 objMessage.Subject = "Title Here"
  objMessage.From = "From@some.address.com"
  objMessage.To = "To@some.address.com"
  objMessage.TextBody = "Message Body"
  objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "Mail Server"
  objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
  objMessage.Configuration.Fields.Update
  objMessage.Send
0
 
LVL 4

Expert Comment

by:Enigma2001
ID: 24134660
sorry code error there. Replace all the objMessage to oMailMessage
0
 

Author Comment

by:SteveSext
ID: 24134711
Hi
Thanks for that..what is

objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "Mail Server"

should these lines be (port 25)
objMessage.Configuration.Fields.Item = objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 25
  objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "FQDN of the hostname"

objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "Mail Server"

0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 4

Expert Comment

by:Enigma2001
ID: 24134726
The "Mail Server" is the name of your mail server
The 25 represents the port
and the other line ... is evading me at the moment.

You can declare those parts so you can just put in the 25 and server name but I only ever use it once in a script so dont bother.
0
 
LVL 4

Accepted Solution

by:
Enigma2001 earned 500 total points
ID: 24134729
0
 

Author Closing Comment

by:SteveSext
ID: 31569766
Great that worked. Thanks
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
In this video we show how to create an email address policy in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Mail Flow…
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now