Is there any way, if an ampscript Lookup is "null" or if there is no value for a specific contact, to tell to Marketing cloud with ampscript NOT TO SEND the email or to prevent from sending the email (instead of sending an email without value or personalization) ?

  • I am not sure about what is the scenario but you can use the ROWCOUNT and LOOKUPROWS Ampscript functions to determine if the contact exists or not in a specific Data Extension, so you can use it as a filter to exclude that contacts from the target who will receive the email.
    – fromero
    Commented May 14, 2019 at 14:17

3 Answers 3


First I would look at your lists and see if there is a way to either adjust your current filters/queries or to create new ones to remove the records prior to send time that do not have the personalization info you need. This is the least process heavy and more efficient option.

If that is not a possibility, I would then aim to use an Exclusion script if possible (Trigger and User-Initiated emails) to validate if the record fits your needs. This will exclude them prior to the rendering of the email and will make sure it does not cost you money by counting as a send still.

Simple script sample:
or for a sample with Lookup - EMPTY(LOOKUP("DE", "FirstName","EmailAddress",emailaddr))

This basically looks at the value for the data extension/list attribute of "FirstName" and if it is empty, returns a value of TRUE but if there is a value inside of it, then the function returns a value of FALSE. The exclusion script works in that if the final value returned is TRUE then it will exclude the record, but if it is returned as FALSE then the record will be pushed forward in the process.

If an exclusion script would not work, then I would move to the RaiseError() function, but I would do so with caution. For although a viable option, there are 2 very important aspects to pay attention to with this.

First, even though the email does not get sent out from SFMC, it will still count towards your totals as a send because it went to the final part of the rendering. This means that even though only 200 of your emails went out, you will still be charged for the 500 others that were prevented via the RaiseError function in the email.

Second, If you do not set it up right, once it gets triggered, it can stop your entire process and only do a partial send. Leaving you with a major PITA process to find who it was sent to, segment the audience and then resend to those that did not get it.

If you notice property 2 in the Function:

Indicates whether function skips send for current subscriber and continues or stops. A value of true skips the send for current subscriber and moves to next subscriber. A value of false stops the send and returns an error. Function defaults to false.

A value of false means that it will halt the whole send. And the function defaults to false if no value is entered. Meaning that you will need to add this value as true in each RaiseError() you use, or it will halt your send.

RaiseError("Default False") will stop your send once triggered once and not move forward to next subscriber


RaiseError("Set to True", true) will stop the send for that subscriber, but then move on to the next subscriber and continue processing the rest of the queue.

  • 1
    Hello Gortonington, thanks a lot for your answer. It sounds logic, we should exclude first through SQL query the contacts that have no value for these fields. Using RaiseError should be the last solution because a send is counted even if the email is not finally sent.
    – Ludivine L
    Commented May 16, 2019 at 13:05
  • @LudivineL - If this answered your question, please be sure to mark the answer as correct (the checkmark next to the answer) so it is easier for others to find/reference if they are facing the same issues. Commented May 20, 2019 at 12:54

Use the RaiserError function in AMPscript.

RaiseError('Don't send to subscriber', true)

Wrap your LookupRows in an IF statement to check RowCount

  • 1
    Thank you very much for your answers!
    – Ludivine L
    Commented May 14, 2019 at 14:39

There is a raiseerror() function you can use during send time.

System returns the error message 'Don't send to subscriber' and stops the send to that subscriber only. 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .