我正在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