Sample code for 30+ languages & platforms
JavaScript Requires Chilkat v11.0.0+

Set and read the sender name and address

See more Email Object Examples

Set FromName and FromAddress separately when your application stores them in separate fields. Assign a formatted mailbox to From when that is the input you have. These fields describe the visible author.

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.
JavaScript
//  Assumes Chilkat is unlocked. See Global Unlock Sample.

var email = new CkEmail();
email.FromName = "Workshop team";
email.FromAddress = "events@example.com";
console.log("Formatted From: " + email.From);
//  Parse a formatted mailbox into its two components.
email.From = "Alex Rivera <alex@example.net>";
console.log("Name: " + email.FromName);
console.log("Address: " + email.FromAddress);