Icon that encapsulates the image's dimensions and other properties.
Here is an example of how these APIs can be used while generating a self-contained HTML document to be included as the HTML body of an email message:
import com.traction.sdk.*;
import com.traction.sdk.view.*;
import com.traction.sdk.sdl.*;
import com.traction.sdk.mail.*;
...
// com.traction.sdk.Context context ...
IncludeManager include = context.getIncludeManager();
SdlEvaluator eval = ctx.getSdlFactory().createSdlEvaluator(context, "com.example.my.template#function");
Scope scope = eval.getScope();
scope.setVariable("myVariable", ...);
SmtpMessage message = context.getSdkFactory().createPersonalSmtpMessage(context);
String htmlContent;
try (IncludeManager.DocumentScope docScope = include.createDocumentScope()) {
include.setDefaultIncludeMode(IncludeManager.ResourceType.CSS, IncludeManager.Mode.INLINE);
include.setDefaultIncludeMode(IncludeManager.ResourceType.JS, IncludeManager.Mode.INLINE);
include.setDefaultIncludeMode(IncludeManager.ResourceType.IMAGE, IncludeManager.Mode.CONTENT_ID);
include.setAutomaticallyIncludeInResponseWhenIncludingInBody(Icon.ImageResourceType.CONTENT, true);
include.setAutomaticallyIncludeInResponseWhenIncludingInBody(Icon.ImageResourceType.FILE_ICON, true);
include.setAutomaticallyIncludeInResponseWhenIncludingInBody(Icon.ImageResourceType.LABEL_ICON, true);
include.setAutomaticallyIncludeInResponseWhenIncludingInBody(Icon.ImageResourceType.ACTION_ICON, true);
include.setAutomaticallyIncludeInResponseWhenIncludingInBody(Icon.ImageResourceType.LOGO, true);
include.setAutomaticallyIncludeInResponseWhenIncludingInBody(Icon.ImageResourceType.PROFILE_PICTURE, true);
htmlContent = eval.eval();
message.addAttachments(docScope.getIncludedFiles());
}
Email Ingestion
com.traction.sdk.mail.MailFilter
Changes
The APIs available on com.traction.sdk.mail.IncomingMessage
have changed. The subject, content and other attributes of the mail message data are now immutable. MailFilter
implementations may inspect that original state, but can only modify the state of the com.traction.sdk.edit.NewReceivedMailEntry
accessible from IncomingMessage
's getNewEntry()
method. These changes were necessary to address some internal consistency issues, and to ensure that the edit SDK implementation can remain coherent in the presence of modifications made both by MailFilter
s, com.traction.sdk.edit.EntryFilters
, and any of the com.traction.sdk.Transformer
s that must be applied as part of TeamPage's normal ingestion pipeline. (Server94227)
Files
com.traction.sdk.file.FileInfo
Embedding URLs
The method getEmbeddingURL()
has been added to the FileInfo
interface to allow implementations to supply special URLs for the purpose of embedding a reference to the resource -- usually an image resource -- for the current context. All built-in implementations know how to correctly select the right sort of URL for the context (based upon the current TokenRendererSet and/or other contextual information), and are optimized to do so without having to perform unnecessary metadata queries whenever possible, which provides a slight performance improvement when many images are embedded in a response.
Outgoing Email
Using Contents of a File for Message Body
com.traction.sdk.mail.Message
now supports using a com.traction.sdk.file.FileInfo
as the message body. The usual use-case for this would be to create a com.traction.sdk.file.TempFile
, populate it with the desired HTML body (which may be quite large), and use that as the message body, e.g.:
import com.traction.sdk.*;
import com.traction.file.*;
import com.traction.sdk.mail.*;
import java.io.IOException;
class Foo {
....
void sendMessage(Context context) throws AuthenticationException, MessagingException, IOException {
Message message = context.getSdkFactory().createPersonalSmtpMessage(context);
message.setSubject("Greetings");
try (TempFile bodyFile = createTransientTempFileForBody(context)) {
try (PrintWriter out = bodyFile.getUtf8PrintWriter()) {
// write body to out
}
message.setBodyHtml(bodyFile);
}
message.send();
}
TempFile createTransientTempFileForBody(Context context) throws IOException {
FileData metadata =
FileData.createInstanceForUnnamedResource("message",
MediaType.HTML_UTF_8.toString(),
null);
return context.getSdkFactory().createNewTransientTempFile(context, null, metadata, null);
}
....
}
com.traction.sdk.mail.Message.ReadyToSend
Clients can now invoke com.traction.sdk.Message
's new getReadyToSend()
method. If the method succeeds and returns a Message.ReadyToSend
object, the client can take this as confirmation that TeamPage was able to open the transport and will be able to send the message, so long as the client creates an otherwise valid message (e.g., with valid recipients and other attributes that are all accepted by the SMTP service). The Message instance can then be sent either by invoking its send()
method, as usual, or via the send()
method on the ReadyToSend
instance. Multiple invocations of the getReadyToSend()
method will return the same instance, and only one send operation can be performed. ReadyToSend
instances are AutoCloseable
; closing the instance will cancel the message if it has not already been sent. This provides a nice way to use ReadyToSend
with a try-with-resources block, e.g.,
import com.traction.sdk.*;
import com.traction.sdk.mail.*;
...
// com.traction.sdk.Context context ...
SmtpMessage message = context.getSdkFactory().createPersonalSmtpMessage(context);
try (Message.ReadyToSend ready = message.getReadyToSend()) {
message.addRecipient("user@example.com", Message.SupportedRecipientType.TO);
message.setSubject("Greetings");
message.setHtmlBody(...);
}
catch (MessagingException e) {
// won't be able to send
}
The new Message
method abort()
will also cancel the message.
General SDK
Access to com.traction.sdk.UserAgent
s
Clients can now access any UserAgent
object by its configuration name, or for any user-agent identification string, via the following new methods in com.traction.sdk.config.ServerConfiguration
:
public abstract UserAgent getUserAgentFromName(String name);
public abstract UserAgent getUserAgentFromUserAgentString(String uaString);
Attachments:
teampage_logo.jpg
Article: Customer5254 (
permalink)
Categories: :Doc:changelog, :Doc:r62
Date: August 3, 2020; 2:39:23 PM Eastern Daylight Time
Author Name: Dave Shepperton
Author ID: shep