Java
Chilkat2 Java
Append Text to an Email Body
See more Email Object Examples
Demonstrates the Chilkat Email.AppendToBody method, which appends additional text to the email's existing plain-text body rather than replacing it. This example sets an initial body and then appends more text.
Background: Setting the body (via
Body or SetTextBody) replaces whatever was there, while AppendToBody adds to it. That is convenient when a message body is assembled in pieces — for example a greeting, then dynamically generated lines, then a signature — without having to concatenate the whole string yourself before assigning it.Chilkat Java Downloads
import com.chilkatsoft.chilkat2.Email;
public class ChilkatExample {
public static void main(String[] args) {
// Demonstrates the AppendToBody method, which appends additional text to the email's
// existing plain-text body.
Email email = new Email();
email.setSubject("AppendToBody example");
// Set an initial body.
email.setTextBody("First line.", "text/plain");
// Append more text to the existing body.
email.appendToBody(" Appended text.");
System.out.println("Body = " + email.getBody());
}
}