CDO email sending, trouble with signature special characters

Hello1

Registered User.
Local time
Today, 08:36
Joined
May 17, 2015
Messages
271
I'm trying to add a html file data to the .HTMLBody.
I'm using a function to read the file data
.HTMLBody = GetFileData(PathOfFile)

Well, it adds my signature and all the formatting but characters like ć, č, š... mess up. Also, it doesn't add the image I have in the html file but the characters are priority now.

I'm writing from my phone, sorry I couldn't be more specific.
Thanks!

Edit:
Code:
Public Function GetTextFileContents(sFilePath As String) As String
    If Dir(sFilePath) <> "" Then
        Dim fso As Object
        Dim ts As Object
        Set fso = CreateObject("Scripting.FileSystemObject")
        Set ts = fso.GetFile(sFilePath).OpenAsTextStream(1, -2)
        GetTextFileContents = ts.ReadAll
        ts.Close
        Set ts = Nothing
        Set fso = Nothing
    End If
End Function

The function which I use to read the file content. When I print it in the debug windows, the GetTextFileContents the weird characters are there.
So I suppose Set ts = fso.GetFile(sFilePath).OpenAsTextStream(1, -2) this line is where it messes up the text. But the -2 is for system default which shouldnt make problems then?
 
Last edited:
Fixed it with this.

Code:
Public Function GetTextFileContents(sFilePath As String) As String
    If Dir(sFilePath) <> "" Then
        Dim objStream, strData
    
        Set objStream = CreateObject("ADODB.Stream")
        objStream.Charset = "utf-8"
        objStream.Open
        objStream.LoadFromFile (sFilePath)
        GetTextFileContents = objStream.ReadText()
        objStream.Close
        Set objStream = Nothing
    End If
End Function
 

Users who are viewing this thread

Back
Top Bottom