1

I am trying to pull the FromAddress and FromName, from a data extension but am not having much luck.

I have setup a sender profile that looks like this:

From Name: %%=v(@fromName)=%%
From Address: %%=v(@fromAddress)=%%

My Data Extension Looks like this:

brandcode
fromname
fromaddress

The Ampscript in my email template looks like this:

Var @fromname, @fromaddress, @brandcode, @row, @rows, @rowcount

Set @brandcode = AttributeValue("Brandcode")

Set @rows = LookupRows("senderinfo", "brandcode", @brandcode)
set @rowCount = rowcount(@rows)

if @rowCount > 0 then

    set @row = row(@rows,1) 
    set @fromname = field(@row,"fromname")
    set @fromaddress = field(@row,"fromaddress")


ENDIF

What I am trying to do is this.

IF Brandcode = AA Then use the fromname and from address for AA

IF Brandcode = BB then use the fromname and from address for BB

My code validates but it uses the "default" sender info and is not using the lookup.

1

2 Answers 2

5

I think the main issue is that you cannot pull the From Name / From Address from inside of the email body.

The order of processing puts the From Name/Address ahead of the HTML Body. Meaning those variables are empty until after they have been declared.

So at this point you have 3 options:

  1. Put the full AMPScript into each item: (This can get messy and hard to edit)

From Name:

%%[ Var @fromname, @fromaddress, @brandcode, @row, @rows, @rowcount

Set @brandcode = AttributeValue("Brandcode")

Set @rows = LookupRows("senderinfo", "brandcode", @brandcode)
set @rowCount = rowcount(@rows)

if @rowCount > 0 then

    set @row = row(@rows,1) 
    set @fromname = field(@row,"fromname")   

ENDIF ]%% %%=v(@fromname)=%%


2. Put the entire script into a content block (My recommendation)

Content Block:

Var @fromname, @fromaddress, @brandcode, @row, @rows, @rowcount

Set @brandcode = AttributeValue("Brandcode")

Set @rows = LookupRows("senderinfo", "brandcode", @brandcode)
set @rowCount = rowcount(@rows)

if @rowCount > 0 then

    set @row = row(@rows,1) 
    set @fromname = field(@row,"fromname")
    set @fromaddress = field(@row,"fromaddress")


ENDIF

From Name: %%[ContentBlockByID("yourID")]%% %%=v(@fromname)=%%

  1. You can just pull directly from the field inside the sendable DE. (I would recommend putting a 'default' value on both of these fields)

From Name: %%fromname%%

Anything you put in the email html will not affect the from name or address - so I believe the above are your only options.

1
  • Thanks for the insight and answer. We currently use option 3 but am looking to change that. Will trial 1 and 2. Prob just go with 1.
    – lyslexic
    Commented Sep 19, 2018 at 12:15
-1

If the information you are trying to pull is within the sendable DE, I would recommend option 3 of @Gortonington's answer.

You can also do it this way:

var @fromName
set @fromName = [fromname]
1
  • Hello Mayorga,welcome to the SFSE community. I personally disagree with your answer. because your ampscript snippets does not contain any output. Furthermore it does not make sense to create a variable, set this variable and then do nothing with it. You can achieve the same with %%fromname%% if this would be inside your dataextension. Remember that the question is about pulling these fields into the sender profile fromname and fromemail and not into the email body. I personally highly disagree to chose the third option because you have duplicate data all over the place. Recommending the second Commented Sep 20, 2018 at 6:34

You must log in to answer this question.

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