Un-Obtainium
asked on
Word document content into an email
Is there any way to get clean html from a word document in VB.net to make it the body of an email. I can get the html into the body of the email but any special characters(ie. bullets, hyphens) in the word document come out as odd characters in the html like squares and unknown shapes. The code I am using to get the html in the email is below. It works, but has unexpected characters in the html.
Public Function SendEmails(ByVal sEmailFrom As String, ByVal sEmailSubject As String, _
ByVal sSMTP As String, ByVal sTo As String, ByVal sCC As String(), _
ByVal sFileName As String) As Boolean
Dim bResult As Boolean = True
Dim oMessage As New MailMessage(sEmailFrom, sTo)
Dim oSMTP As New SmtpClient
oSMTP.Host = sSMTP
oMessage.Subject = sEmailSubject
For Each sCCAddress As String In sCC
oMessage.CC.Add(sCCAddress)
Next
oMessage.IsBodyHtml = True
oMessage.Body = GetWordContent(sFileName)
Try
oSMTP.Send(oMessage)
Catch ex As Exception
MsgBox(ex.Message)
bResult = False
End Try
Return bResult
End Function
Private Function GetWordContent(ByVal sFileName As String) As String
Dim sResult As String = String.Empty
Try
Dim oStream As StreamReader
oStream = File.OpenText(sFileName)
sResult = oStream.ReadToEnd
Catch ex As Exception
End Try
Return sResult
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.