Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Special Characters of French being converted into black diamond with question mark into Email on Server but at localhost everything is ok

Example:- Conversion of special characters

Real Word:- Converted into Mail
d’avoir = d�avoir
à = �
procédure = proc�dure

What I have tried:

var msg = new SendGridMessage();
string to = objContractorOperationEmail.To;
msg.AddTo(to);
msg.SetSubject(objContractorOperationEmail.Subject);
msg.AddContent(MimeType.Html, objContractorOperationEmail.Body);
Send(msg);

public void Send(SendGridMessage msg)
{
var client = new SendGridClient(_mailConfig.Value.SendgridKey);
msg.From = new EmailAddress(_mailConfig.Value.FromEmail, _mailConfig.Value.FromName);
client.SendEmailAsync(msg);
}
Posted
Updated 14-Sep-21 22:31pm
v5
Comments
CHill60 15-Sep-21 9:22am    
Why are you continuously updating your question. I have already supplied you with the answer.

1 solution

There was an issue raised against the git project for this - see Special characters in transactional templates · Issue #714 · sendgrid/sendgrid-csharp · GitHub[^]
 
Share this answer
 
Comments
.NET- India 16-Sep-21 7:59am    
I have encoded my body string into "ISO-8859-1", but now string being converted into "question mark(?)" from "black diamond question mark" as given below...
d�avoir = d?avoir
à = ?
procédure = proc?dure

Following given code i'm using for conversion.....
-----------------
public string EncodeISO(string name)
{
Encoding objISO = Encoding.GetEncoding("ISO-8859-1");
string s_unicode = name;

// Convert to ISO-8859-1 bytes.
byte[] isoBytes = objISO.GetBytes(s_unicode);

string str = objISO.GetString(isoBytes);
return str;
}
CHill60 16-Sep-21 8:53am    
It says at the bottom of the thread I gave you a link to "I believe this issue is now fixed at the API level. Please let us know if you continue to experience any issues."
You need to raise an Issue there. Not sure why you are encoding to that instead of UTF-8 but I haven't read all the documentation on the link.
.NET- India 16-Sep-21 9:07am    
I have also encoded my code on "UTF-8" but still getting same result. So i would have to make some changes at my code to run it on Server because on localhost it's already running no need to encode my code......

Encoding objISO = Encoding.GetEncoding("ISO-8859-1");
Encoding objUTF = Encoding.UTF8;

// Unicode string.
string s_unicode = name;

// Convert to ISO-8859-1 bytes.
byte[] isoBytes = objISO.GetBytes(s_unicode);

// Convert to UTF-8.
byte[] utf8Bytes = Encoding.Convert(objISO, objUTF, isoBytes);

string utf8str = objUTF.GetString(utf8Bytes);
return utf8str;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900