Site Map Contact Us Home
E-mail Newsletter
Subscribe to get informed about
Clever Components news.

Your Name:
Your Email:
 
SUBSCRIBE
 
Previous Newsletters
 




Products Articles Downloads Order Support
Customer Portal      

Build E-Mail Message

The easiest way to compose a new mail message is to use the BuildMessage method from the MailMessage component. This method automatically creates an appropriate MIME body structure.

A list of the overloaded BuildMessage methods allows you specifying pretty much of all possible combinations of input parameters. Please check out the examples below for more details.

If you decide to add attachments manually, you will have to compose a corresponding MIME body structure yourself.
Please refer the following article for more details Adding text and attachments to the E-mail message

Example 1

If you call to the BuildMessage method with a non-empty AText parameter only, a simgle message with one body part will be generated.

clMailMessage.BuildMessage('Hello World!', '');
clMailMessage.From.Email := 'john @ domain.com';
clMailMessage.ToList.Add('steve @ another.com');
clMailMessage.Subject := 'Hello';
messageSource := clMailMessage.MessageSource;

This method creates new email in Plain Text format:

Show Message Source

Example 2

If you call to the BuildMessage method with both non-empty AText and AHtml parameters, a multi-part alternative message with two body parts will be generated.

clMailMessage.BuildMessage('Hello World!', '<html><body><p>Hello World!</p></body></html>');
messageSource := clMailMessage.MessageSource;

The method above creates multipart message in Rich Text (HTML) format:

Show Message Source

Example 3

If you call to the BuildMessage method with both non-empty AText and AHtml parameters where AHtml contains image including, the resulting message will be in Rich Text (HTML) format with embedded images:

clMailMessage.BuildMessage('Hello World!',
   '<html><body><p>Hello World!</p><img src="c:\pictures\icon.gif"></body></html>',
   ['c:\pictures\icon.gif'], []);
messageSource := clMailMessage.MessageSource;

As a result, the following message will be generated:

Show Message Source

Example 4

With BuildMessage you can easily add any number of file attachments to all message formats mentioned above.

clMailMessage.BuildMessage('Hello World!', ['c:\archives\file1.zip', 'c:\archives\file2.zip']);
messageSource := clMailMessage.MessageSource;

This method creates new email in Plain Text format with one attached file:

Show Message Source

    Copyright © 2000-2021