我正在尝试使用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/

10-09 08:54