I have a data extension like below. Now when sending emails to the list it sends multiple emails to a single subscriber based on the record. As an example as - [email protected] is two times in the table so it sends two separate emails. I need to do two things -

  1. Send a single email if there multiple records with the same email address.
  2. Add all the details to a single email for a single user with multiple records.

Currently, I am using the below code and it shows all rows value in a single email for a similar email address. The output of the code is listed below -

email_address: [email protected]
Row 1, firstName: Eileen, lastName: Dover
Row 2, firstName: Eileen, lastName: Dover

So it shows two different record values in a single email but it sends the email two times as there are two records for the email address - [email protected]

var @rows, @row, @rowCount, @i, @email_address, @user_code, @first_name, @last_name, @order_details

set @email_address = email_address
set @user_code = user_code

set @rows = LookupRows("TestDE","email_address", @email_address)
set @rowCount = rowcount(@rows)

output(concat("email_address: ", @email_address))

if @rowCount > 0 then

  for @i = 1 to @rowCount do

    var @first_name, @last_name, @order_details
    set @row = row(@rows, @i) /* get row based on counter */
    set @first_name = field(@row,"first_name")
    set @last_name = field(@row,"last_name")

    ]%% <br>
    Row %%=v(@i)=%%, firstName: %%=v(@first_name)=%%, lastName: %%=v(@last_name)=%%


  next @i ]%%

%%[ else ]%%

No rows found

%%[ endif ]%%

Here is the table structure -

UserID FirstName LastName OrderDetails ItemNumber Email
123456 Eileen Dover abcdef 01 [email protected]
567890 John White xyzuvv 02 [email protected]
123456 Eileen Dover abrcdd 03 [email protected]
567890 John White ertvvb 04 [email protected]
456789 Jane Banks uerthy 05 [email protected]

So can anyone please help me to figure out the issue so that it will send a single email for all the records if there similar email address multiple times. Hope that makes sense.


  • Thank you for updating your question. As I already wrote - it is limited how much you can do, by using ampscript, to prevent multiple emails being sent to the same recipient email address. I would instead recommend to query the data extension above, and deduplicate it into a new sendable data extension. You will just lookup all the records from the original one in your ampscript, while the sendout happens to the deduplicated one. Dec 7, 2023 at 9:53
  • Thanks Lukas, I am looking at your solution but I can't see the image you shared - i.stack.imgur.com/TOKSo.png Can you please share the image again as I need to check that. Dec 7, 2023 at 16:44
  • Here is an alternative link for the image: drive.google.com/file/d/1FL5n9JavlBUOETbkfoqpxvjZmlDXP8Rb/… Dec 8, 2023 at 8:29

2 Answers 2


You can try splitting the data set into two data extensions as shown below.

enter image description here

Then you can use AMPscript lookup to get the details of UserInfo records.

Join will be something like below

EmailRepository.UniqueId = UserInfo.EmailId

You can use the EmailRepository as the sendable data extension

Refer below for examples to AMPscript lookup


  • Remember to mark my answer as accepted if it has been helpful Jan 12 at 10:59

You are not writing how you are sending these emails. If you are using e.g. guided send in Email Studio, you have the option of deduplicating subscribers:

enter image description here

This will only send one single email to a specific email address, even if it is present multiple times in the sendable data extension under multiple subscriber keys.

Then, you could indeed use LookupRows, using email address as lookup criteria to include the details from multiple rows into a single email.

  • Hi Lukas, Thanks for your answer. I have included more details with another questions if you can check - salesforce.stackexchange.com/questions/414141/… Actually, I am developing the email and marketers are responsible for data extension options. Thanks! Dec 6, 2023 at 16:41
  • @MonowarHossain rather than posting a similar question, please update this one with this additional information Dec 6, 2023 at 17:55

You must log in to answer this question.

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