I am using AMSCRIPT to personnalize some sender details in an email block at the end of the email. This block contains several lines :
- name of the account
- first name, last name,
- phone
- email adress
- postal adress
I would like to avoid to display a break line if the fields are empty.
I had tried a code based on researchs I did in StackEchange but when I test it, I still have break lines in the empty fields. I have no doubt I am doing something wrong.
Here is the code I used on the beginning of the email :
%%[
var @accountname, @lastname, @firstname, @phone, @emailadress, @postaladress
SET @accountname = AttributeValue("Opportunity:Account:Name")
SET @lastname = AttributeValue("Opportunity:NomCommercial__c")
SET @firstname = AttributeValue("Opportunity:PrenomCommercial__c")
SET @phone = AttributeValue("Opportunity:TelephoneCommercial__c")
SET @emailadress = AttributeValue("Opportunity:EmailCommercial__c")
SET @postaladress = Concat(@Opportunity:Account:BillingStreet, "", @Opportunity:Account:BillingPostalCode, "", @Opportunity:Account:BillingCity)
%%=iif(not empty(@accountname),concat(@accountname,"<br/>"),"")=%%
%%=iif(not empty(@firstname),@firstname,"")=%%%%=iif(not empty(@lastname ),concat("",@lastname),"")=%%<br/>
%%=iif(not empty(@phone),concat(@phone,"<br/>"),"")=%%
%%=iif(not empty(@emailadress),concat(@emailadress,"<br/>"),"")=%%
%%=iif(not empty(@postaladress),concat(@postaladress,"<br/>"),"")=%%
endif
]%%
On the email body at the bottom of the email I had added the output function :
%%=v(@accountname)=%%
%%=v(@firstname)=%% %%=v(@lastname)=%%
%%=v(@phone)=%%
%%=v(@emailadress)=%%
%%=v(@postaladress)=%%
I do not know :
- how to apply the iif condition that I had put on the beginning of the email with my v function
- and if I have to use the v function to display only the fields that are not empty and not to display break lines between lines if the fields are empty.
Thanks for your precious help
%%=v()=%%
functions.