I would like to automatically fill the "From Name" field of our sender profile.

Using AMPScript i created a new Sender Profile with %%=v(@FromName)=%% in my "From Name" field.

Then in my template-based email i added this code in the header: %%[Var @FromName SET @FromName = "WR"]%% %%=v(@FromName)=%%

When i send this email my dynamic "From Name" doesn't get filled and Marketing Cloud uses the default name of my account even if the AMPScript is executed correctly because "WR" appears in the top of my email.

I've been looking for a solution but i couldn't find anything usefull. I already asked to Marketing Cloud support and they enabled everything was necessary to use the dynamic sender but they couldn't help me with the code.

2 Answers 2


The issue comes from the Sender Profile (SP) being processed prior to the email. This means that any variables set inside the email will not be rendered as they are set after the variable is called in the SP.

The logic you used above utilizing variables from the email works for subject line and preheader as they are processed after the email, so the variables are filled with any information set inside the email.

To counter this, I usually put the full ampscript logic inside of the Sender Profiles From Name and Address, followed by the variable call.


%%[Var @FromName SET @FromName = "WR"]%% %%=v(@FromName)=%%

If your AMPscript is significant, it might be better to utilize a Content Block to house it and then call this block inside the SP.



Where the content block would output the @FromName Variable.

I usually utilize the raw code inside the SP as it keeps it all contained and simple.

You also can set an attribute (profile attribute on list or data extension field) and call that directly inside the SP.

  • Thanks for your help. Now i have a clearer vision on how it works, but the email is not being sent. I moved my code inside a content block and then call it inside the sender profile. Marketing cloud says that everything is fine, but the email doesn't go off. Am i doing something wrong? Jan 9, 2018 at 14:16
  • I would first check the tracking to see if the email errored. If so, I would validate your ampscript - usually best done in a landing page. If ampscript is fine, I would test your email using a different sender profile and ensure the error is not in your email. Jan 9, 2018 at 14:27
  • I didn't notice that the email is being sent in the spam folder because the From Name is blank. Should i use a different method to output my variable inside the block instead of %%=v(@FromName)=%%? Jan 9, 2018 at 14:50
  • I would first verify that the block is correctly outputting the variable. Then try outputting the variable directly in the sender profile. e.g. %%[ ContentBlockbyKey("myContentBlock") ]%% %%=v(@FromName)=%%. Jan 9, 2018 at 15:06
  • 1
    It worked, thank you very much for your help, i appreciate it. May i ask you another question? Is it possible to make this solution more "dynamic" reading any information from the email that is being sent even if it is rendered after the SP? Jan 9, 2018 at 15:38

Consider how code/AMPScript will process - it will run Top Down with the From Name and From Email address processed first in the header.

If AMPScript processes the header of the email first, it's going to come across your code %%=v(@FromName)=%% but as @FromName at this point it won't be able to retrieve or process the value - therefore it defaults it. AMPScript then continues down to the body of the email where you then have %%[Var @FromName SET @FromName = "WR"]%% %%=v(@FromName)=%%

Now AMPScript knows what @FromName is - however it can't go back and set the header, it's continuing the top-down process.

A solution around this is to :

  1. Create a content box and set an External Key e.g. SenderEmail
  2. Create a content box and set an External Key e.g. SendName
  3. Inside your Content Boxes add your ampscript to set Email Name, Email address - though could be done as a simple Set @FromName = 'something' or you could also do a lookup to a data extension.
  4. In you sender profile, add the following to your From Name / From Email boxes %%=ContentAreaByKey("SenderEmail")=%%

Now when you send the email, the email will be processed top-down and this time it will load the content box, where it can then execute the AMPScript.

You must log in to answer this question.

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