Currently we are using SendGrid Inbound Parse to receive emails. We handle the Inbound Parse webhook request by Azure HttpTrigger function implmented in C# (.NET 6). When the received email is in UTF-8 encoding, everything's okay. However, when we tried to receive email in shift_jis encoding, headers are okay, but japanese characters in text and html are garbled.
From Inbound Parse request, we got the charsets as below:
- subject: UTF-8
- to: UTF-8
- from: UTF-8
- cc: UTF-8
- html: shift_jis
- text: shift_jis
And the string we got directly from request.form["text"] (or "html") was already garbled like "�e�L�X�gshiftJis-007" (should be "テキストshiftJis-007"), so we cannot use string in request directly.
Then we tried to convert (System.Text.Encoding.Convert method) it from charset encoding (shift_jis) to utf-8, and the result was different from original string but still unreadable "?e?L?X?gshiftJis-007".
Our questions are: When using C# HttpTrigger Azure function to handle Inbound Parse webhook request (request data is passed through AspNetCore.)
- What encoding is in html/text string in Inbound Parse webhook request when the email is send in encoding other than UTF-8?
- How to read text and html in shift_jis encoding (or other encodings excluding UTF-8) correctlyfrom an Inbound Parse webhook request?