JavaScript Requires Chilkat v11.0.0+
JavaScript
Put a web link in an HTML email
See more Email Object Examples
An ordinary hyperlink belongs in the HTML body. It needs no related MIME part. Provide the URL in the text alternative for readers that display plain text.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat
v11.4.0 or greater.
var success = false;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
var email = new CkEmail();
email.From = "Workshop team <events@example.com>";
success = email.AddTo("Alex Rivera","alex@example.net");
if (success !== true) {
console.log(email.LastErrorText);
return;
}
email.Subject = "Workshop directions";
// Use an absolute URL because the message has no website base URL.
success = email.AddPlainTextAlternativeBody("Directions: https://example.com/workshop/map");
if (success !== true) {
console.log(email.LastErrorText);
return;
}
success = email.AddHtmlAlternativeBody("<p><a href='https://example.com/workshop/map'>View workshop directions</a></p>");
if (success !== true) {
console.log(email.LastErrorText);
return;
}
success = email.SaveEml("directions.eml");
if (success !== true) {
console.log(email.LastErrorText);
return;
}
console.log("Saved directions.eml.");