我正在尝试使用 Visual Basic 6.0 将 html 文件附加到电子邮件。当光标出现在 Open strFile For Binary Access Read As #hFile 行时,它给出错误“Error encoding file - Bad file name or number”。非常感谢您的所有帮助和支持。
Dim handleFile As Integer
Dim strValue As String
Dim lEventCtr As Long
handleFile = FreeFile
Open strFile For Binary Access Read As #handleFile
Do While Not EOF(hFile)
' read & Base 64 encode a line of characters
strValue = Input(57, #handleFile)
SendCommand EncodeBase64String(strValue) & vbCrLf
' DoEvents (occasionally)
lEventCtr = lEventCtr + 1
If lEventCtr Mod 50 = 0 Then DoEvents
Loop
Close #handleFile
Exit Sub
File_Error:
Close #handleFile
m_ErrorDesc = "Error encoding file - " & Err.Description
Err.Raise Err.Number, Err.Source, m_ErrorDesc
End Sub
最佳答案
这就是为什么您应该始终使用 OPTION EXPLICIT
的原因。您应该检查 EOF(handleFile)
而不是 EOF(hFile)
。
关于html - 在 VB 6.0 中将 HTML 文件附加为电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2101199/