I am developing an Excel macro, allowing the user to send an e-mail via Gmail, with Excel data converted to PDF as an attachment. To do this, I am using Eledo PDF generator and Integromat. I am using Integromat Webhook feature by sending to it the data taken directly from Excel with the use of HTTP request. Overall, the code works correctly. However, I cannot manage to send properly special characters, especially the polish ones i.e. "ą", "ę", "ż", "ź", "ś", "ć", "ł". These, as far as I know, are not included in the ASCII character codes provided in Excel. The JSON is sent, yet those characters are converted to some inappropriate, random ones, such as these: "ążóÃ", corresponding to the letters: "ążóò". I tried making the HTTP request directly from browser and manually inserting such characters as the values in JSON, and they seem to be retrieved correctly, thus, this is definitely an Excel issue. I tried setting the request header charset to UTF-8, replacing those letters in strings with their char equivalents, changing encoding with Integromat, to no avail. I have run out of ideas, none of the forum posts seem to answer my question, I found only a tiny clue as to what may be happening:
"The symptoms indicate that the JSON string which was originally in UTF-8 encoding was written to the HTTP response using ISO-8859-1 encoding and the webbrowser was instructed to display it as UTF-8. If it was written using UTF-8 and displayed as ISO-8859-1, then you would have seen aériennes. If it was written and displayed using ISO-8859-1, then you would have seen a�riennes." - I tried sending the word "aériennes" and it was retrieved as "aériennes".
Below, I am attaching my code. I will be eternally grateful for any advice!
Private Sub CommandButton7_Click()
Dim objHTTP As Object
Dim Mesg As String, Subj As String, URL As String, Json As String, WebhookID As String, HookString As String, Email As String
Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0")
Subj = Range("O125").Value
Mesg = Range("O127").Text
Email = Range("O126").Value
HookString = "Title=" & Range("N13").Value & "&" & "Material=" & Range("S13").Value & "&" & "Adhesive=" & Range("T13").Value & _
"&" & "Dimensions=" & Range("N14").Value & "&" & "Width=" & Range("O14").Value & "&" & "Length=" & Range("P14").Value & "&" & "Colours=" & Range("Q14").Value & _
"&" & "NoC=" & Range("R14").Value & "&" & "Mtype=" & Range("S14").Value & "&" & "Adtype=" & Range("T14").Value & "&" & "NoE=" & Range("N16").Value & _
"&" & "1=" & Range("O16").Value & "&" & "2=" & Range("P16").Value & "&" & "3=" & Range("Q16").Value & "&" & "4=" & Range("R16").Value & "&" & "5=" & Range("S16").Value & _
"&" & "6=" & Range("O17").Value & "&" & "7=" & Range("O18").Value & "&" & "8=" & Range("P18").Value & "&" & "9=" & Range("Q18").Value & "&" & "10=" & Range("R18").Value & "&" & "11=" & Range("S18").Value & _
"&" & "12=" & Range("O19").Value & "&" & "13=" & Range("P19").Value & "&" & "14=" & Range("Q19").Value & "&" & "15=" & Range("R19").Value & "&" & "16=" & Range("S19").Value & _
"&" & "17=" & Range("O20").Value & "&" & "18=" & Range("P20").Value & "&" & "19=" & Range("Q20").Value & "&" & "20=" & Range("R20").Value & "&" & "21=" & Range("S20").Value & _
"&" & "NoEoR=" & Range("N17").Value & "&" & "Value=" & Range("N18").Value & "&" & "Po1000=" & Range("N19").Value & "&" & "PoR=" & Range("N20").Value & "&" & "Photopolymers=" & Range("N22").Value & _
"&" & "NaS=" & Range("N23").Value & "&" & "Date=" & Range("N24").Value & "&" & "piece=" & Range("O22").Value & "&" & "PoPiece=" & Range("P22").Value & "&" & "Diecut=" & Range("R22").Value & _
"&" & "PoD=" & Range("S22").Value & "&" & "Offer=" & Range("O24").Value & "&" & "OfferN=" & Range("P24").Value
WebhookID = "xyzxyzxyzxyzxyzxyzxyzxyz"
URL = "https://hook.integromat.com/" & WebhookID & "?&Subj=" & Subj & "&Mesg=" & Mesg & "&Email=" & Email & "&" & HookString
objHTTP.Open "GET", URL, False
objHTTP.setRequestHeader "Content-type", "application/json"
objHTTP.setRequestHeader "accept-language", "pl-PL,pl;q=0.9,en-US;q=0.8,en;q=0.7"
objHTTP.setRequestHeader "user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36"
objHTTP.send (Json)
End Sub