I have an ASP.Net application that allows a user to write text to a Telerik RadEditor control and then send an email.
For some reason, I sometimes get strange characters appearing in the created letter.
For example, if I put the word Tests in the RadEditor field and send it ... an email message appears with the text changed to: Testâ € ™ s .
It seems that instead of ' instead of ' the symbol was used, because if I use it later, the text will be displayed just fine. If I pulled out a saved entry in the ASP.Net application interface, it looks just fine. It also looks great when I look at the text in the recorded MS SQL table in which it was stored.
I use MailMessage to create email. Ive checked that the string is sent at a point just before I use SmtpClient to send the message, and that looks just fine. As soon as the e-mail message appears, I get weird text (Testâ € ™ s).
I assume that I have a problem with encoding / decryption, but I'm not sure how I will fix it.
Does anyone have any ideas?
Thank!
Continued --->
I tried adding it to the constructor of my email class with / without mybase, but that did not affect.
Public Sub New(ByVal EmailDate As DateTime, ByVal LogoPath As String)
MyBase.New()
MyBase.BodyEncoding = Encoding.GetEncoding("iso-8859-1")
‘BodyEncoding = Encoding.GetEncoding("iso-8859-1")
Me.EmailDate = EmailDate
Me.LogoPath = LogoPath
End Sub
, , SmtpClient, .
Try
returnEmail.BodyEncoding = Encoding.GetEncoding("iso-8859-1")
Dim smtpCli As New SmtpClient
smtpCli.Send(returnEmail)
Catch ex As Exception
ScriptManager.RegisterStartupScript(Me, Me.GetType, "smtpError", "alert('There was an error sending the email:\n* " & ex.Message & "');", True)
End Try