Delphi Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Delphi Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
DH Key Exchange
DSA
Email
Email Object
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
SMTP
Socket
Spider
SFTP
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression

More Examples...
Byte Array
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate

Unreleased...
Bzip2
LZW
Icon

Type Conversion

 

Article: Understanding COM References in Delphi

Send Email with Custom Header Fields

Download Chilkat Email ActiveX

Delphi example code showing how to add custom headers to an email. Also shows how to remove a header, and to iterate over the headers in an email object to see what header fields exist.

// Adding custom header fields to your email can be accomplished by
// calling the email.AddHeaderField method.
procedure TForm1.Button21Click(Sender: TObject);
var
  email: IChilkatEmail2;
  ok: Integer;
  n: Integer;
  i: Integer;

begin
  // A ChilkatMailMan2 ActiveX component was dropped onto the Delphi
  // form, and this became the Form's member variable "ChilkatMailMan21".

  ChilkatMailMan21.UnlockComponent('Anything for 30-day trial');
  ChilkatMailMan21.SmtpHost := 'smtp.comcast.net';

  email := ChilkatMailMan21.NewEmail();
  email.Subject := 'Email with custom headers sent from a Delphi program!';
  email.From := 'Chilkat Support <support@chilkatsoft.com>';
  email.AddTo('Chilkat Admin','admin@chilkatsoft.com');
  email.Body := 'This email was mailed from a Delphi program...';

  // To add custom headers, call AddHeaderField.  If a field with the header name
  // already exists, AddHeaderField will replace it.
  email.AddHeaderField('X-Company','Chilkat Software');
  email.AddHeaderField('abc-123-blah-blah','ya ya ya ya ya');

  // To remove a header field, call RemoveHeaderField.
  email.RemoveHeaderField('X-Abcdef');

  // To see what header fields already exist, you can iterate over the
  // names.
  n := email.NumHeaderFields;
  for i := 0 to n-1 do
    ListBox1.Items.Add(email.GetHeaderFieldName(i));

  ok := ChilkatMailMan21.SendEmail(email);
  if (ok = 0) then
        ChilkatMailMan21.SaveLastError('errorLog.xml');

end;

 

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2008 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Email Component · XML Parser