Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Node.js Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(Node.js) Convert Embedded HTML Images to Multipart/Related CID References

Demonstrates how to convert HTML images that are inline/embedded within the HTML to CID references to multipart/related MIME parts.

Note: This example requires Chilkat v9.5.0.78 or greater.

Install Chilkat for Node.js and Electron using npm at

Chilkat npm packages for Node.js

Chilkat npm packages for Electron

on Windows, Linux, MacOS

var os = require('os');
if (os.platform() == 'win32') {  
  var chilkat = require('@chilkat/ck-node23-win64'); 
} else if (os.platform() == 'linux') {
    if (os.arch() == 'arm') {
        var chilkat = require('@chilkat/ck-node23-linux-arm');
    } else if (os.arch() == 'arm64') {
        var chilkat = require('@chilkat/ck-node23-linux-arm64');
    } else {
        var chilkat = require('@chilkat/ck-node23-linux-x64');
    }
} else if (os.platform() == 'darwin') {
  var chilkat = require('@chilkat/ck-node23-darwin-universal');
}

function chilkatExample() {

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    // This example converts the following email with image data embedded directly in the HTML,
    // to the MIME shown at the bottom of this page.
    // If the HTML contains multiple embedded images, the call to email.ConvertInlineImages will convert all of them.

    // MIME-Version: 1.0
    // Date: Tue, 30 Apr 2019 11:36:34 +0200
    // Message-ID: <E5DB5F8A65D671FB4822B22F5309411838F2FC93@PC0VDL0W013>
    // Content-Type: text/html; charset="windows-1252"
    // Content-Transfer-Encoding: quoted-printable
    // X-Priority: 3 (Normal)
    // From: <admin@chilkatsoft.com>
    // To: Matt <matt@chilkat.io>
    // Subject: Test
    // 
    // <html xmlns=3D"http://www.w3.org/1999/xhtml">
    // <body><p>
    // <img src=3D"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEA3ADcAAD/2=
    // wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYFBgYGBwkIBgcJBwYGCAsICQoKCgoK=
    // BggLDAsKDAkKCgr/2wBDAQICAgICAgUDAwUKBwYHCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgo=
    // ...
    // 4zzS3ww+5/8AyR//2Q=3D=3D" width=3D"58" height=3D"66" alt=3D"" style=3D"bord=
    // er-width:0px;" /></body>
    // </html>

    var email = new chilkat.Email();
    var success = email.LoadEml("qa_data/eml/embedded_html_image.eml");

    email.ConvertInlineImages();
    console.log(email.GetMime());

    // The MIME after moving the image data to a separate MIME sub-part:

    // MIME-Version: 1.0
    // Date: Tue, 30 Apr 2019 11:36:34 +0200
    // Message-ID: <E5DB5F8A65D671FB4822B22F5309411838F2FC93@PC0VDL0W013>
    // Content-Type: multipart/related; boundary="------------020808080005060904000806"
    // X-Priority: 3 (Normal)
    // From: <admin@chilkatsoft.com>
    // To: Matt <matt@chilkat.io>
    // Subject: Test
    // 
    // --------------020808080005060904000806
    // Content-Type: text/html; charset=windows-1252
    // Content-Transfer-Encoding: quoted-printable
    // 
    // <html xmlns=3D"http://www.w3.org/1999/xhtml">
    // </head></head><body><p>
    // <img src=3D"cid:CID-1f73052c-32a7-4abb-8e9d-0afb58c17eed@CHILKATSLICE" widt=
    // h=3D"58" height=3D"66" alt=3D"" style=3D"border-width:0px;" /></body>
    // </html>
    // 
    // 
    // 
    // --------------020808080005060904000806
    // Content-Type: image/jpeg; name="image_95EA3073134C.jpeg"
    // Content-Transfer-Encoding: base64
    // Content-ID: <CID-1f73052c-32a7-4abb-8e9d-0afb58c17eed@CHILKATSLICE>
    // 
    // /9j/4AAQSkZJRgABAQEA3ADcAAD/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYF
    // BgYGBwkIBgcJBwYGCAsICQoKCgoKBggLDAsKDAkKCgr/2wBDAQICAgICAgUDAwUKBwYHCgoKCgoK
    // ...
    // 5bmGF7e42pOwUxrFNEQOcLGw6vX2Yv7NfxbWLYfB67s84vrf/wCLoor8r424ZwGYZkqlSUk+VLRr
    // /Jn2mS8QYzC0Woxi9eqf+aGr+zX8XUyW8K9/+f8Ag/8AjlO/4Zs+Ln/Qqf8Ak/b/APxyiivkXwPl
    // H88/vj/8ifUR4zzS3ww+5/8AyR//2Q==
    // 
    // --------------020808080005060904000806--

}

chilkatExample();

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.