1

So I'm implement mandrill in asp classic. Everything was fine so far, the mail was sent but I got a problem. When I send a parameter with special character, the content in email got converted. For example, The value I sent to mandrill is Göran but in email, it got convert to Göran.

I have tried to change CodePage session but it didn't work. Using ajax jQuery and send the same value, the email look fine. Do I need to set up something in request

Response.CodePage = 65001
Session.CodePage = 65001
Set HttpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")
HttpReq.open "POST", "https://mandrillapp.com/api/1.0/messages/send-template.json", False
HttpReq.setRequestHeader "Content-Type", "application/json"
HttpReq.send(mandrillData)
user692942
  • 16,398
  • 7
  • 76
  • 175
DarknessZX
  • 686
  • 3
  • 12
  • Try and `Server.HTMLEncode` the values. – Dijkgraaf Feb 12 '18 at 07:14
  • @Dijkgraaf why would you HTML encode when the body is being sent as JSON? They likely need to [specify `;charset=utf-8`](https://stackoverflow.com/q/9254891/692942) on the `Content-Type` request header. – user692942 Feb 12 '18 at 08:24

1 Answers1

1

Encoding in Classic ASP

When working with encoding in Classic ASP there is a check list you need to follow;

  1. Is the ASP page saved using required encoding? If you want to work with UTF-8, the page needs to first be saved using UTF-8 encoding.
  2. Does the ASP preproccessor know to process the ASP page using the specific encoding? You do this by specifying Response.CodePage and Response.Charset in your ASP page.
  3. When sending encoded data to a 3rd party, do you tell them what to expect? For example, when sending JSON the Content-Type header is important but so is the charset argument to specify how the content is encoded.

    Call HttpReq.setRequestHeader("Content-Type", "application/json; charset=utf-8")
    Call HttpReq.Send(mandrillData)
    

Useful Links

user692942
  • 16,398
  • 7
  • 76
  • 175