Hi,
How would you create a typology rule to rule out devlieries with a size greater than X (35K)?
According to docs, max size should be 35K.
Delivery performances best practices | Adobe Campaign
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
@god_prophet,
Please use the below script in control typology rule and this will stop the delivery if the size of the content is more than 35KB.
// JavaScript code to check email size in Adobe Campaign
var sg = new StringGroup("nms:core");
var maxSizeInBytes = 35 * 1024; // 35KB = 35 * 1024 bytes
var sizeInBytes = 0;
// Safely access HTML content length
if (delivery && delivery.content && delivery.content.html && delivery.content.html.source) {
sizeInBytes += delivery.content.html.source.length; // Add HTML content length
}
// Safely access text content length
if (delivery && delivery.content && delivery.content.text && delivery.content.text.source) {
sizeInBytes += delivery.content.text.source.length; // Add text content length
}
// Log size for debugging
logInfo("Delivery size log: Email size (" + (sizeInBytes / 1024).toFixed(2) + " KB)");
// Check if size exceeds limit
if (sizeInBytes > maxSizeInBytes) {
logWarning("Delivery aborted: Email size (" + (sizeInBytes / 1024).toFixed(2) + " KB) exceeds maximum allowed size of 35 KB.");
return false; // Exclude the delivery
}
return true; // Allow the delivery
Let me know if this works.
Thanks
Sushant Trimukhe
@god_prophet,
Please use the below script in control typology rule and this will stop the delivery if the size of the content is more than 35KB.
// JavaScript code to check email size in Adobe Campaign
var sg = new StringGroup("nms:core");
var maxSizeInBytes = 35 * 1024; // 35KB = 35 * 1024 bytes
var sizeInBytes = 0;
// Safely access HTML content length
if (delivery && delivery.content && delivery.content.html && delivery.content.html.source) {
sizeInBytes += delivery.content.html.source.length; // Add HTML content length
}
// Safely access text content length
if (delivery && delivery.content && delivery.content.text && delivery.content.text.source) {
sizeInBytes += delivery.content.text.source.length; // Add text content length
}
// Log size for debugging
logInfo("Delivery size log: Email size (" + (sizeInBytes / 1024).toFixed(2) + " KB)");
// Check if size exceeds limit
if (sizeInBytes > maxSizeInBytes) {
logWarning("Delivery aborted: Email size (" + (sizeInBytes / 1024).toFixed(2) + " KB) exceeds maximum allowed size of 35 KB.");
return false; // Exclude the delivery
}
return true; // Allow the delivery
Let me know if this works.
Thanks
Sushant Trimukhe
Hi @SushantTrimukheD it worked ty.
Just one question: why did you use this line:
var sg = new StringGroup("nms:core");
It was a leftover from other script? I don't see the variable "sg" being used in other line... also... I commented the line and rule still worked. Ty