Challenge
https://ampscript30.com/ampscript-challenge-day4/
To display different messages on the email depending on whether the email addresses are correct.
Solution
Hello %%=ProperCase(FirstName)=%%,
Thank you for referring a friend to our perks program!
%%[
SET @referral = ReferralEmail
IF IndexOf(@referral, '@') > 0 THEN
SET @msg = concat('We received your referral to ', @referral, '.')
ELSE
SET @msg = 'Please provide us with a valid referral email address.'
ENDIF
]%%
%%=v(@msg)=%%
Best regards,
Wanderer Outdoor Equipment

Preview


Summary
Although this way works, it’s better to use IsEmailAddress(EmailAddress) function to evaluate if the email address is valid. If there are only two conditions, IIF(condition, value to return if condition is true, value to return if condition is false) can be used as an alternative.