Attach HTML file as email in VB 6.0

I am trying to attach a html file to email using Visual Basic 6.0. when the cursor comes to Open the strFile line for binary access Read as #hFile , it gives the error "Error Coded File - Bad name or file number ". Please, all your help and support will be highly appreciated.

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
+3
source share
2 answers

That is why you should always use OPTION EXPLICIT. You should check EOF (handleFile) instead of EOF (hFile).

+3
source

, . , , , , ...

+2

Source: https://habr.com/ru/post/1729224/


All Articles