0

I am hitting my head to get this done for the last two days but not succeeded. I want to have dynamic 'From name' and 'Email Address' based on the values populated in the Email.

I have created two HTML content Blocks.

First Block Contains the following code :

%%[var @Email
   Set @Email = 'Test@Test.com' 
]%% 
%%=v(@Email)=%%

Second block contains :

%%[var @Name 
   Set @Name= 'Test' 
]%% 
%%=v(@Name)=%%
  • I used the above two content block as a reference block in my email.
  • Then in the sender profile, i have selected "Use the specified information:"

  • Then in From Name : %%=contentBlockByKey("FromName")=%%

  • Then in From Email: %%=contentBlockByKey("FromEmail")=%%

But what i am getting in from name and from Email when i got the email is :

</div>
<div data-marker= "wrapper" style= "" class= "stylingblock-content-wrapper">

Can anyone tell what i have missed?

2

You wrote:

I want to have dynamic 'From name' and 'Email Address' based on the values populated in the Email.

You won't be able to populate a FROM address based on values within the email. It's an order of operations issue. Once the content of the email is being read, then the FROM field has already passed.

I have gotten around this by putting the value desired in the sending DE.

  • You also just throw all of the AMPscript directly into the Sender Profile From Name / From Address itself. – AnonWonderer Aug 1 '18 at 17:56
  • I am trying to follow the this link – R Suri Aug 2 '18 at 6:47
  • I am getting these values from Sales Cloud using various AMPScript functions. So can't use that whole Ampscript on Sender Profiles from name and Email. – R Suri Aug 2 '18 at 7:28
0

Harley is right, you can't set dynamic values for fromname/fromemail from the email itself b/c of order of operations. But, you could have logic based on data pulled from the DE/Subscriber attributes inside a Code Snippet or Content Area (NOT a Content Block) and use ContentBlockByName() or ContentAreaByName() (depending on which you use) to pull in the Code Snippet/Content Area.

Also, you can put that logic directly in the From Email and From Name fields.

Here's an example of the coding directly in the fields where all From Names are stored in a separate Data Extension (DE), and the audience has a field of SubscriberBrand whose value matches the Brand value in the DE:

%%=LookUp("ENT.FromNames", "from_name", "Brand", "%%SubscriberBrand%%")=%%

Make note, I've quoted the %%SubscriberBrand%% value! This is because of order of operations funkiness... The interpreter will do a first pass and convert %%SubscriberBrand%% to the string Cool Stuff (assuming Cool Stuff is a brand in my business). So first pass leaves your code like this:

%%=LookUp("ENT.FromNames", "from_name", "Brand", "Cool Stuff")=%%

Then it will execute the lookUp. If I had left the quotes out, it would have instead looked like this after the interpreter's first pass:

%%=LookUp("ENT.FromNames", "from_name", "Brand", Cool Stuff)=%%

Then the LookUp call is going to try to find constants Cool and Stuff and will fail horribly and you won't know why (b/c the errors caused are only visible on the backend).

Here's another more complex example:

%%=IIF("%%EventCategoryID%%" == 'CB34459E-XXXX-4550-XXXX-XXXXXXXXXXX', 'Cool Stuff', IIF("%%EventCategoryID%%" == 'CB34459E-YYYY-4550-YYYY-ZZZZZZZZZZZ', 'Super Rad', 'Boffo!')=%%

Notice that both instances of %%EventCategoryID%% are again wrapped in quotes. This code uses nested IIF() functions to mimic an IF/ELSEIF/ELSE scenario. It's long, and all on one line (sorry for the side-scrolling), but it will do the trick. When you get more than a few options, though, storing in a separate DE is usually best, assuming you can account for all possibilities.

  • I am trying to follow this link – R Suri Aug 2 '18 at 6:50
  • Hi @RSuri, if you use standard Content Blocks, they get wrapped in <div>s. You'll have to write your content to Code Snippets instead: help.salesforce.com/… – Sam Whitmore Aug 2 '18 at 20:22

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.