Problem creating Scripting.FileSystemObject

Results 1 to 2 of 2

Thread: Problem creating Scripting.FileSystemObject

  1. #1
    Join Date
    Dec 1969

    Default Problem creating Scripting.FileSystemObject

    Hi,<BR><BR>I have a component running in MTS which I use to send emails - In this component I use the following code :<BR><BR>***************************************** ************************<BR>Const gulProcName = "SendMailWithTemplate"<BR> <BR> &#039;*** A filesystem object and a textstream<BR> Dim objFileSystem As New Scripting.FileSystemObject<BR> Dim objTemplateFile As Scripting.TextStream<BR> <BR> &#039;*** String to hold the message body<BR> Dim strBody As String<BR> <BR> &#039;*** Index<BR> Dim intI As Integer<BR> <BR>On Error GoTo ErrH<BR><BR>&#039;*** What we want to do is to construct the message body and call<BR>&#039;*** sendmail to actually send the thing.<BR> <BR> &#039;*** Open the template file for reading...<BR>Set objTemplateFile = objFileSystem.OpenTextFile(strTemplateFile)<BR> <BR>&#039;*** Read the entire file into our string<BR> strBody = objTemplateFile.ReadAll<BR> &#039;*** Close the file<BR> objTemplateFile.Close<BR> Set objTemplateFile = Nothing<BR><BR>*********************************** *****************************<BR><BR>An error occurs at the following line: <BR>Set objTemplateFile = objFileSystem.OpenTextFile(strTemplateFile)<BR><BR >Error: Class does not support automation or does not support expected interface<BR><BR>strTemplateFile = a path to a text file on the hard drive. <BR><BR>I also changed the code as follows<BR><BR>*********************************** *****************************<BR>Dim objFileSystem As Scripting.FileSystemObject<BR>Set objFileSystem = CreateObject("Scripting.FileSystemObject")<BR>**** ************************************************** **********<BR><BR>When this change was made I got a type mismatch error on the 2nd line above.

  2. #2
    Join Date
    Dec 1969

    Default RE: Problem creating Scripting.FileSystemObject

    Have you tried the option parameter for the OpenTextFile method. OpenTextFile(FileName, IOMode, Create)<BR>FileName = File on your system<BR>IOMode = 1 is Reading, 2 is Writing and 8 is Appending<BR>Create is True or False<BR><BR>Try setting these parameters and see if that makes a difference. <BR><BR>Also check and make sure you have the proper permissions set to be able to Read and Write to that directory.<BR><BR>Tim

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts