Sample code for 30+ languages & platforms
VBScript

Set the Email From Header

See more Email Object Examples

Demonstrates the Chilkat Email.From property, which contains the sender name and email address as they appear in the MIME From header, such as John Smith <john.smith@example.com>. The From, FromName, and FromAddress properties are different views of the same MIME From header. This example sets From and reads back all three views.

Background: The internet message standard (RFC 5322) formats a sender as an optional display name followed by the address in angle brackets: Display Name <user@domain>. The display name is what a mail client typically shows in the inbox, while the bracketed address is the actual routing destination. Note that this visible From header is separate from the SMTP envelope sender used during delivery, which is why spoofing a From is possible — and why standards like SPF, DKIM, and DMARC exist to verify it.

Chilkat VBScript Downloads

VBScript
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)

'  Demonstrates the Email.From property, which contains the sender name and
'  email address as they appear in the From header, such as
'  "John Smith <john.smith@example.com>".
'  From, FromName, and FromAddress are different views of the same From header.

set email = CreateObject("Chilkat.Email")

email.From = "John Smith <john.smith@example.com>"

outFile.WriteLine("From = " & email.From)
outFile.WriteLine("FromName = " & email.FromName)
outFile.WriteLine("FromAddress = " & email.FromAddress)

outFile.Close