Sample code for 30+ languages & platforms
PowerBuilder

Add a To Recipient to an Email

See more Email Object Examples

Demonstrates the Chilkat Email.AddTo method, which adds a single direct (To) recipient. The first argument is the friendly display name and the second is the email address. This example adds one To recipient and prints the resulting count.

Background: The To recipients are a message's primary audience — the people it is directly addressed to. Each recipient is stored as a display name plus an email address, which together render in the header as Bob <bob@example.com>. Call AddTo once per recipient, or use AddMultipleTo to add several from a single comma-separated string.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
oleobject loo_Email

//  Demonstrates the AddTo method, which adds a single direct (To) recipient.
//  The 1st argument is the friendly (display) name, and the 2nd is the email address.

loo_Email = create oleobject
li_rc = loo_Email.ConnectToNewObject("Chilkat.Email")
if li_rc < 0 then
    destroy loo_Email
    MessageBox("Error","Connecting to COM object failed")
    return
end if
loo_Email.Subject = "AddTo example"
loo_Email.From = "alice@example.com"

loo_Email.AddTo("Bob","bob@example.com")

Write-Debug "NumTo = " + string(loo_Email.NumTo)


destroy loo_Email