Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Problem sending e-mail from script

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,45028
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Problem sending e-mail from script
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 Problem sending e-mail from script - 3/26/2007 8:39:37 PM   
  markmcrobie

 

Posts: 314
Score: 0
Joined: 12/12/2006
Status: offline
I've decided to post this question separate from other thread, as it's a differnet problem:

I'm trying to use ginolard's example template to send an e-mail from VBS:

sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
  With cdoConfig.Fields
      .Item(sch & "sendusing") = 2 ' cdoSendUsingPort
      .Item(sch & "smtpserver") = "IXA-EX1.uk.int.amec.com"
      .update
  End With
Set objMessage = CreateObject("CDO.Message")
  With objMessage
      Set .Configuration = cdoConfig
        .Subject = ""
      .From = "mark.mcrobie@amec.com"
      .To = "mark.mcrobie@amec.com"
      .TextBody = "121"
      .AddAttachment ""
      .Send
  End With

I got the server bit from going into Outlook > Tools > E-mail Accounts > Microsoft Exchange Server, then copy/pasted what was in the box labelled Microsoft Exchange server.  I've also tried using "localhost" and "exchange" (both with quotes as above) and I always get the same error (and always about 10 seconds after double clicking the .vbs file):

80040213 Source: CDO.Message.1 - The transport failed to connect to the server (line 19, char 8, which is my .Send statement)

 
 
Post #: 1
 
 RE: Problem sending e-mail from script - 3/26/2007 8:53:46 PM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
Can you Telnet to port 25 on that machine?  If not, it's probably not the SMTP server

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to markmcrobie)
 
 
Post #: 2
 
 RE: Problem sending e-mail from script - 3/26/2007 9:06:02 PM   
  markmcrobie

 

Posts: 314
Score: 0
Joined: 12/12/2006
Status: offline
Well if I open telnet.exe and type:

o IXA-EX1.uk.int.amec.com 25

I get a message back saying "Could not open connection to the host, on port 25.  Connect failed.

Exact same message if I omit the 25 bit, and leave it as the default port of 23:

"Could not open connection to the host, on port 23.  Connect failed."

(in reply to markmcrobie)
 
 
Post #: 3
 
 RE: Problem sending e-mail from script - 3/26/2007 9:19:57 PM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
Sounds like that's not the SMTP server then.  Can you check with your Exchange admin?

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to markmcrobie)
 
 
Post #: 4
 
 RE: Problem sending e-mail from script - 3/26/2007 9:29:47 PM   
  markmcrobie

 

Posts: 314
Score: 0
Joined: 12/12/2006
Status: offline
What do I need to check? What port number the exchange server is on?

If so, is there no other way of checking that?

(in reply to ginolard)
 
 
Post #: 5
 
 RE: Problem sending e-mail from script - 3/26/2007 9:36:16 PM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
SMTP is, nearly always, on port 25.  That's the default port and there's no real reason to change it.  You just need to know the correct server name

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to markmcrobie)
 
 
Post #: 6
 
 RE: Problem sending e-mail from script - 3/26/2007 9:42:40 PM   
  markmcrobie

 

Posts: 314
Score: 0
Joined: 12/12/2006
Status: offline
Like I said I got the server name I'm using from Tools > E-mail Accounts > Microsoft Exchange Server in Outlook.

Does it matter we're using Exchange here at work? Does that still count as SMTP?

(in reply to ginolard)
 
 
Post #: 7
 
 RE: Problem sending e-mail from script - 3/26/2007 9:47:17 PM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
I'm not an Exchange admin so can't say for certain (I know that if I take my Exchange server from Outlook it works just fine).  However, your setup may be different.  You really need to speak to the admins there.

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to markmcrobie)
 
 
Post #: 8
 
 RE: Problem sending e-mail from script - 3/26/2007 9:59:34 PM   
  markmcrobie

 

Posts: 314
Score: 0
Joined: 12/12/2006
Status: offline
There's not much chance of them giving me the info :-(

(in reply to ginolard)
 
 
Post #: 9
 
 RE: Problem sending e-mail from script - 3/26/2007 10:07:07 PM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
I don't see why not.  All you are doing is sending emails via SMTP.  Effectively you are cutting out the middle man of Outlook.

You won't know if you don't try

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to markmcrobie)
 
 
Post #: 10
 
 RE: Problem sending e-mail from script - 3/26/2007 11:11:48 PM   
  markmcrobie

 

Posts: 314
Score: 0
Joined: 12/12/2006
Status: offline
I work for the Ministry of Defence in a nuclear submarine base, they get a bit funny about things like this

(in reply to ginolard)
 
 
Post #: 11
 
 RE: Problem sending e-mail from script - 3/26/2007 11:17:54 PM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline


The nation's safety is in the hands of a VbScripter everyone!  RUN FOR YOUR LIVES!  ;)

I don't really know what else to suggest I'm afraid.

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to markmcrobie)
 
 
Post #: 12
 
 RE: Problem sending e-mail from script - 3/27/2007 12:29:02 AM   
  dm_4ever


Posts: 2726
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
lol Run!!!!...hahahaha

Like ginolard stated you will need to know the name or ip of an SMTP server for this to work.  Alternately, I suppose you could use the outlook client.  The problem is outlook will not allow the script to automatically send it for you...it complains because it thinks it may be a virus/worm trying to do it.  You can get up to the point of sending and then it is up to you.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ginolard)
 
 
Post #: 13
 
 RE: Problem sending e-mail from script - 3/27/2007 12:54:53 AM   
  markmcrobie

 

Posts: 314
Score: 0
Joined: 12/12/2006
Status: offline
Ok, I've asked the IT folks to give me the SMTP server address, we'll see what happens.

Until then, let's go down the Outlook route - what's the 1st step?

(in reply to dm_4ever)
 
 
Post #: 14
 
 RE: Problem sending e-mail from script - 3/27/2007 1:08:53 AM   
  markmcrobie

 

Posts: 314
Score: 0
Joined: 12/12/2006
Status: offline
Well believe it or not they gave me the smtp address.

However I'm getting the exact same error:

Error: "The transport failed to connect to the server."
Code: 80040213
Source: CDO.Message.1

(in reply to markmcrobie)
 
 
Post #: 15
 
 RE: Problem sending e-mail from script - 3/27/2007 1:10:20 AM   
  dm_4ever


Posts: 2726
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Here is an example:  http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=4&txtCodeId=6480

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to markmcrobie)
 
 
Post #: 16
 
 RE: Problem sending e-mail from script - 3/27/2007 1:14:35 AM   
  markmcrobie

 

Posts: 314
Score: 0
Joined: 12/12/2006
Status: offline
Right, I CANNOT telnet the address using:

o <address> 25

or

o <address>

However I CAN ping it from a cmd window, which gives me the IP address

Putting this IP address into my code instead of server name like this:

.Item(sch & "smtpserver") = "10.200.1.31"

gives a different error:

Error: The message could not be sent to the SMTP server.  The transport error code was 0x800ccc15.  The server response was not available"
Code: 80040211
Source (null)

(in reply to markmcrobie)
 
 
Post #: 17
 
 RE: Problem sending e-mail from script - 3/27/2007 1:22:19 AM   
  markmcrobie

 

Posts: 314
Score: 0
Joined: 12/12/2006
Status: offline
Just had a thought.

Our PC's here have McAfee VirusScan Enterprise 8.0.0 installed.  In the On-Access Scan Properties page, a thing called ScriptScan is Enabled (and greyed out, I can't untick it).

It says:

"ScriptScan scans JavaScript and VBScript scripts that are executed by the Windows Scripting Host.  WSH is used by Internet Explorer and Outlook.  If an unwanted script is detected it is not allowed to execute."

Could this be the problem?

I should add though that all my other scripts work fine (although admittedly none of them try to send stuff via smtp or anything like that)

(in reply to markmcrobie)
 
 
Post #: 18
 
 RE: Problem sending e-mail from script - 3/27/2007 1:39:09 AM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
ScriptScan - yuck.  The bane of my bloody life that thing.

If they've been willing to give you the SMTP address I would venture to suggest they may know why you can't use Port 25 via a script.

However, if you want to go down the Outlook route, you can.  As already stated, Outlook will complain about it being a virus/worm unless you install something called Outlook Redemption

http://www.dimastr.com/redemption/

it's little tricky to use but the instructions on the website are pretty good.

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to markmcrobie)
 
 
Post #: 19
 
 RE: Problem sending e-mail from script - 3/27/2007 1:51:48 AM   
  markmcrobie

 

Posts: 314
Score: 0
Joined: 12/12/2006
Status: offline
Ok, I'm happy to go down the Outlook route, and to stop the warning I'll get it to display the message before sending:

'Sub SendAttach()
   Dim objOutlook
   Dim objMail
   Dim strMsg
   Const olMailItem = 0
   Set objOutlook = CreateObject("Outlook.Application")
   Set objMail = objOutlook.CreateItem(olMailItem)
   objMail.To = "mark.mcrobie@amec.com"
   objMail.Subject = "Transfer to Navynet" 
   objMail.Attachments.add("C:\test.txt")
   objMail.Body = "The attached files are to be placed onto the Navynet PC"
   objMail.Display 'Use objMail.Display to display before sending, otherwise call objMail.Send to send without reviewing
   Set objMail = Nothing
   Set objOutlook = Nothing
'End Sub

(the Sub and End Sub are commented out so I can run it for test purposes as a standalone script)

However my big problem, which I'm stuck with, is how to get it to attach the files.  I have all the file names that have been renamed by my big script in an array (arrFiles).

I can prove the names in the array are fine by putting:

MsgBox Join(arrFiles,vbCrLf)

At the end of my big script - this produces a message box with all the new file names, which is basically a list of the files I want to attach.

I have the path to these files stored in objPath, and I have the file names stored in an array.  I presume it can't be TOO difficult to get the code above to attach these?

(in reply to ginolard)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Problem sending e-mail from script Page: [1] 2   next >   >>
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts