Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript error 462

Status
Not open for further replies.

Kevin Mortimer

Programmer
Oct 12, 2017
3
ZA
I have a simple vbscript which sends an email through outlook. The vbscript works fine on most machines except one machine which returns an error of 462. Can anyone help me resolve this issue.

Code:
Dim OutApp
 Dim objNS
 Dim OutMail
 Dim strbody
 Dim SigString
 Dim Signature

 Set OutApp = CreateObject("Outlook.Application")
 Set objNS = OutApp.GetNamespace("MAPI")
 OutApp.Session.Logon
 Set OutMail = OutApp.CreateItem(0)

newsignature = Replace( "<html><head><meta http-equiv=Chr(34)Content-
TypeChr(34) content=Chr(34)text/html; charset=utf-8Chr(34)></head><body>
<font face=Chr(34)TahomaChr(34)><font size=2>Dear<br><br><br><br>Kind 
regards</font></font> <br><br> </body></html>", "Chr(34)", """")

On Error Resume Next
 With OutMail
          .To = "kevin@inlinesolutions.co.za"
          .CC = ""
          .BCC = ""
          .Subject = "test"
          .HTMLBody = newsignature
           Err.Clear
.Attachments.Add("C:\Users\Kevin Mortimer\Desktop\62983.pdf")
          If Err.Number <> 0 Then
          MsgBox "Error Attaching Document:( " & Err.Number & " ) " & Err.Description
          Err.Clear
          End If
          .Send
 End With

 On Error GoTo 0
 Set Signature = Nothing
 Set SigString = Nothing
 Set strBody = Nothing
 Set OutMail = Nothing
 Set objNS = Nothing
 Set OutApp = Nothing
 
One description I read said

Error: 462
Error (Hex): 1CE
Source: Microsoft VBScript runtime error
Description: The remote server machine does not exist or is unavailable

which might indicated you can't reach the file location or you don't have permissions to it.

Simi

 
Read these threads:

The suggestion is:
[ol 1]
[li]to use CreateObject only when GetObject is Nothing[/li]
[li]to use GetNamespace("MAPI")[/li]
[/ol]

i.e. finally something like this -see the 3.link above
Code:
 On Error Resume Next
  Set OutlookApp = GetObject(, "Outlook.Application")
  On Error GoTo 0
  If OutlookApp Is Nothing Then
    Set OutlookApp = CreateObject("Outlook.Application")
  End If
  Dim Session As Object
  Set Session = OutlookApp.GetNamespace("MAPI")
  Session.Logon
 
Thanks all for the advice. I have made those changes but i now get this error, see attached. Just to give you an idea of what is happening. I am trying to send emails to about 10 people. The vbscript files are created and then run. Is there a limit to how many of these vbscript files can run at the same time?
 
 http://files.engineering.com/getfile.aspx?folder=48e356e3-698c-4fbf-8958-b21beb849f3b&file=Screen_Shot_10-17-17_at_11.11_AM.PNG
Is there a limit to how many of these vbscript files can run at the same time
I thought that you run only one script file at the same time.
 
i run a looping script in my database that cycles through the recipients and creates the custom vbscript code for each recipients, runs that code then goes onto the next recipient and does the same. THis happens very fast but has never been a problem before. I have been able to do this on over 100 recipients before with no problem. Just having a problem on this one machine. May be a problem with the Outlook installation. I will try run the loop with some pauses to see if that helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top