Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Sending email from a VB script

Posted on 2009-04-13
6
Medium Priority
?
274 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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 2000 total points
ID: 24134729
0
 

Author Closing Comment

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

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to install and use the NTBackup utility that comes with Windows Server.
After hours on line I found a solution which pointed to the inherited Active Directory permissions . You have to give/allow permissions to the "Exchange trusted subsystem" for the user in the Active Directory...
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…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
Suggested Courses

730 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