通过命令提示符运行时,我的VB脚本中出现错误800A03EE

时间:2018-10-16 21:04:07

标签: vbscript outlook office365

我正在Windows上通过命令提示符运行,并且在第24行和第34个字符处收到警报

代码示例如下:

Sub CatchMe()

      Dim outobj, mailobj
      Dim strFileText
      Dim objFileToRead

      Set outobj = CreateObject("Outlook.Application")
      Set mailobj = outobj.CreateItem(0)
      strFileText = GetText("C:\Users\Yatheesh.Sathyanaray.STDC\Documents1.txt")

        With mailobj
        .To = "yatheesh.satyanarayana@stratogent.com"
        .Subject = "Testmail"
        .Body = strFileText
        .Display
      End With

      'Clear the memory
      Set outobj = Nothing
      Set mailobj = Nothing

    End Sub

    Function GetText(sFile As String) As String
       Dim nSourceFile As Integer, sText As String
       nSourceFile = FreeFile
       'Write the entire file to sText
       Open sFile For Input As #nSourceFile
       sText = Input$(LOF(1), 1)
       Close
       GetText = sText
    End Function

1 个答案:

答案 0 :(得分:-1)

它与您提供的代码一起在我的机器上工作。我已经在Excel文件中对其进行了测试,并复制了您的代码,如下所示:

enter image description here

但是,我注意到您使用了一个名为“ FreeFile”的属性,使用时看起来好像没有。

相关问题