Sample code for 30+ languages & platforms
PowerBuilder

Send to a File-Based Distribution List

See more Email Object Examples

Demonstrates the Chilkat Email.FileDistList property. Set this property to send an email to a list of recipients stored in a plain-text file — one recipient per line, blank lines ignored, no comments. Setting it is equivalent to adding a CKX-FileDistList header field. When the email is sent, MailMan reads the file and delivers to each recipient. This example sets the distribution-list file and prints the MIME.

Background: MIME headers whose names start with X- are non-standard, application-specific fields. Chilkat extends this idea with its own CKX- prefix: these fields let you attach instructions to an email object that Chilkat understands, but they are stripped before transmission so they never appear in the delivered message. They are preserved when you save/load the email as XML or MIME, making them handy for storing send-time metadata like a distribution list.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
oleobject loo_Email

//  Demonstrates the Email.FileDistList property.
//  Setting this property causes MailMan to send the email to a list of
//  recipients stored in a plain-text file (one recipient per line).
//  Setting it is equivalent to adding a CKX-FileDistList header field.

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 = "Newsletter"
loo_Email.Body = "Hello subscribers!"
loo_Email.From = "news@example.com"

//  The file contains one recipient email address per line.
loo_Email.FileDistList = "qa_data/txt/recipients.txt"

Write-Debug "FileDistList = " + loo_Email.FileDistList

//  The CKX-FileDistList header field is present in the saved MIME, but CKX-
//  fields are never transmitted when the email is actually sent.
Write-Debug loo_Email.GetMime()


destroy loo_Email