1

I have a journey which sends an email. The email contains an AMPscript pulling content blocks in. Is is possible to NOT sent the email if there are no content blocks in the email?

SET @CONTACT_ID = CONTACT_ID
SET @Rows_tv2 = LookupRows("TR_VELKOMST_VAS_MAIL_SUBS_tv2","CONTACT_ID", @CONTACT_ID)
SET @Rows_wype = LookupRows("TR_VELKOMST_VAS_MAIL_SUBS_Wype","CONTACT_ID", @CONTACT_ID)
SET @Rows_deezer = LookupRows("TR_VELKOMST_VAS_MAIL_SUBS_Deezer","CONTACT_ID", @CONTACT_ID)

IF RowCount(@Rows_tv2) == 0 then
SET @tv2_block = ContentBlockbyID(28651) 

  ENDIF

IF RowCount(@Rows_wype) == 0 then
SET @wype_block = ContentBlockbyID(26469) 

  ENDIF

IF RowCount(@Rows_deezer) == 0 then
SET @deezer_block = ContentBlockbyID(25834) 

  ENDIF

   ]%%

%%=v(@tv2_block)=%%
%%=v(@wype_block)=%%
%%=v(@deezer_block)=%%

So if

@Rows_tv2 > 0 AND @Rows_wype > 0 AND @Rows_deezer > 0

THEN DONT SEND EMAIL

2 Answers 2

8

I would recommend using Exclusion Scripts if possible. You can find a good explanation of the feature in this video by Eliot Harper.

The exclusion script will be executed prior to sending the email, hence the email sends will not be counted towards your supermessage limits. If you are using RaiseError, the email sends will still count, but the email will of course not be sent.

Both solutions will help you achieve what you need, and I admit that RaiseError will in some cases be easier to implement.

3
  • Hi Lukas - This is perfect! Thanks. I will try this out right away!
    – Martin Ho
    Aug 15, 2019 at 9:42
  • I managed to make it work. Thank you very much!
    – Martin Ho
    Aug 15, 2019 at 12:08
  • 1
    Det var så lidt, @MartinHo! Aug 15, 2019 at 12:10
4

Have you tried using the RaiseError function to skip the send to that subscriber when there is no content available?

if empty(@YourContent) then
RaiseError('Error message', true)
endif

Good usage example here: https://ampscript.guide/raiseerror/

2
  • Hi Daithi - Thank you for your input. I've looked at the funktion and it would work, but it would count the supressed emails as sent and therefore I can't use it.
    – Martin Ho
    Aug 15, 2019 at 9:37
  • RaiseError() "Please note that because the system pre-processes and builds these emails, tracking and reporting numbers include these emails despite the errors and may cause inaccuracies. Use this function to handle the errors of a small number of subscribers, rather than as a method to segment out large numbers of subscribers. Instead, use query activities and exclusion lists to handle your segmentation needs."
    – jake314159
    Oct 1, 2019 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.