I have an email link icon in the footer of my email template. I want to be able to change the link of the email address in the footer dynamically depending on the 'from email' of the sender profile in marketing cloud email studio. How would I go about doing this? Thanks
I don't think this is possible without some workaround. The build process for an email handles email content and job configuration in separate steps and from what I understood by now the pairing of sender profile with the message itself happens after the message and contained AMPScript is evaluated.
You can check the order of operation in the documentation. The point of script evaluation is when the message is matched with subscribers. This step is also what you simulate when you click "Preview and Test" in the email editor. At this time the Sender profile is not yet assigned to the message.
The thread mentioned by fromero explains how a single sender profile can be made dynamic. This is something that you could possible use to solve your issue. Dynamic sender profiles do not need this FROM NAME attribute and data extension field name stuff by the way. You just need to start any lookup based on the subscriber key value.
- Create a lookup data extension that associates sender email addresses with a subscriber attribute or subscriber data extension field value (region, language, SF record owner, ...)
- Create a code snippet in Content Builder with AMPScript which first gives you the subscriber attribute (or data extension field) value based on the subscriber key and then looks up the appropriate email address in the lookup data extension. Set a variable @SenderEmail for the final result (or any other name. I will use this for further reference). Make sure to set a default sender address as fallback in your AMPScript. The following is an example of a dynamic sender profile script I deployed for a client based on the local branch ('Filiale') a contact is associated with ('Bevorzugte Filiale')
%%[var @Filiale, @Filialmail Set @Filiale = Lookup('Contact_Salesforce', 'Bevorzugte_Filiale__c', 'Id', _subscriberkey) if not empty (@Filiale) then Set @Senderemail = Lookup('Filialen', 'MC_FilialEmail__c', 'Filialnummer__c', @Filiale) else Set @Senderemail = "email@example.com" endif ]%%
- Use the following code to call the script in the dynamic sender profile. 123 stands for the Id of the content element you created.
Use the same process logic for your sender profile FROM NAME if required (you would also have to add a corresponding field in your lookup data extension)
In the Email itself insert the %%=TreatAsContent(ContentBlockById('123'))=%% call anywhere above the footer element where you need to personalize the address
Use %%=v(@SenderEmail)=%% for the email address tag
Why the external content block? The advantage of the approach with an "external" content block is that you only have to edit one element when you have to adjust the logic somehow. Also, most errors that might break your sender profile can already be found in the email preview with one major exception: Always make sure beforehand that any email addresses used in this process are validated/verified. This is something the email preview doesn't check.
Please comment if you need some context on the AMPScript functions