I am trying to figure out if I can use AMPScript in the body of an email to find out the name of the List or Data Extension the email is being sent to and then do something based on which condition is met. Does that make sense?

So basically, if I am sending an email and my Data Extension name is DE1 then do something in AMPScript. If it's DE2, do something different.


1 Answer 1


I think you're looking for the _DataSourceName personalization string.

This value captures any audience object sent to. This covers lists, data extensions, groups, and filters.



if _DataSourceName == "DE1" then

  /* something for DE1 */


  /* something for DE2 */ 



You may need to experiment with it if your send is every sent to more than one DE.

Update 2020-07-07

You can get a bunch of info about journey interactions via REST API. It'll give you all the details about the send context and email definition, etc. Technically, you could pull this data in an Automation with a Script Activity and store it in a DE. Similar to this, except with a REST call instead of WSProxy retrieve on the SOAP object.

  • Dude you are awesome. How come I couldn't find that in the docs? Is this kind of stuff listed anywhere? Commented Jun 28, 2017 at 21:15
  • 1
    The Personalization Strings and AMPScript Functions pages are my most frequently visited links. Commented Jun 28, 2017 at 21:21
  • Yes I looked there but did not see it. Commented Jun 28, 2017 at 21:24
  • 1
    @AdamSprings so this has been really helpful in the past. I found it doesn't work with Journeys. Do you have any experience with that? For some reason, in a journey you'd think it would reference the entry point DE, but it references All Subscribers Commented Aug 3, 2018 at 20:51
  • 1
    Since Journey sends are triggers, you may have noticed that the auto-created TSDs don't have DEs associated with them, which makes sense that the _dataSourceName isn't populated. Commented Jul 7, 2020 at 14:23

You must log in to answer this question.

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