{"id":10116,"date":"2026-04-01T15:37:10","date_gmt":"2026-04-01T14:37:10","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=10116"},"modified":"2026-04-01T15:37:11","modified_gmt":"2026-04-01T14:37:11","slug":"convert-email-eml-to-html","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/convert-email-eml-to-html\/","title":{"rendered":"Convert Email (EML) to HTML"},"content":{"rendered":"\n<p>eml-to-html.ps1<\/p>\n\n\n\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"powershell\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"false\">param (\n    [Parameter(Mandatory = $true, Position = 0)]\n    [string]$InputFile\n)\n\nif (-not (Test-Path $InputFile)) {\n    Write-Error \"Bestand niet gevonden: $InputFile\"\n    exit 1\n}\n\n$raw = Get-Content $InputFile -Raw\n\nif ($raw -notmatch \"Content-Type:\\s*text\/html\") {\n    Write-Error \"Geen HTML-part gevonden in dit EML-bestand.\"\n    exit 1\n}\n\n# Pak alles NA Content-Type: text\/html\n$htmlPart = ($raw -split \"Content-Type:\\s*text\/html\", 2)[1]\n\n# Verwijder headers van de MIME-part\n$htmlBody = ($htmlPart -split \"\\r?\\n\\r?\\n\", 2)[1]\n\n# --- Quoted-printable decoding ---\n# 1) line continuations (= aan einde regel)\n$htmlBody = $htmlBody -replace \"=\\r?\\n\", \"\"\n\n# 2) =XX hex decoding\n$bytes = [System.Text.Encoding]::ASCII.GetBytes($htmlBody)\n$decodedBytes = New-Object System.Collections.Generic.List[byte]\n\nfor ($i = 0; $i -lt $bytes.Length; $i++) {\n    if ($bytes[$i] -eq 61 -and $i + 2 -lt $bytes.Length) { # '='\n        $hex = [char]$bytes[$i + 1] + [char]$bytes[$i + 2]\n        if ($hex -match '^[0-9A-Fa-f]{2}$') {\n            $decodedBytes.Add([Convert]::ToByte($hex, 16))\n            $i += 2\n            continue\n        }\n    }\n    $decodedBytes.Add($bytes[$i])\n}\n\n# Charset (default utf-8)\n$encoding = [System.Text.Encoding]::UTF8\n$decodedHtml = $encoding.GetString($decodedBytes.ToArray())\n\n$outputFile = [System.IO.Path]::ChangeExtension($InputFile, \".html\")\n$decodedHtml | Out-File $outputFile -Encoding UTF8\n\nWrite-Host \"HTML ge\u00ebxtraheerd naar:\"\nWrite-Host \"  $outputFile\"\n<\/pre><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>eml-to-html.ps1<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-10116","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/10116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=10116"}],"version-history":[{"count":1,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/10116\/revisions"}],"predecessor-version":[{"id":10117,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/10116\/revisions\/10117"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=10116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=10116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=10116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}