Analyse email about its domain using velocity | Community
Skip to main content
New Participant
October 22, 2022
Question

Analyse email about its domain using velocity

  • October 22, 2022
  • 2 replies
  • 2726 views

Hi everyone, 

 

I like to check the email address for specific domains using velocity/email scripting. But for some reasons it is not working for me. 

Attempt 1 - Using contains

 

#set($mail = "wolfram.lotz@xy-c.com") $mail.contains("xy-c.com")

 

this works fine

 

#set($mail= "{{lead.Email Address}}") $mail.contains("xy-c.com") $mail

 

contains is always false

but $mail output shows the correct domain

 

Attempt 1 - Using split (to check later for equal)

 

#set($mail = "wolfram.lotz@xy-c.com") #set($domain= $mail.split("@")) $domain[1]

 

This works fine. Domain is shown correct. 

 

 

#set($mail = "{{lead.Email Address:default=edit me}}") #set($address= $mail.split("@")) $address[0]

 

 This split does not work. It shows the whole email instead of just the part before the @

Note: I'm checking this within the email, which is why you see ":default=edit me" here. 

I checked as well the following post: https://nation.marketo.com/t5/product-discussions/velocity-splitting-a-string-into-an-array/td-p/144641

 

#set ($string = "ABCD/GIST/SPIT") #set ($output = $string.split('/')) $output[0]

 

 That code is working totally fine as well. But even trying to use a unicode u0040 instead of the @-char does not change anything.

Does anybody have an idea?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

SanfordWhiteman
New Participant
October 22, 2022

P.S. the way to match a domain is $lead.Email.endsWith("@example.com"), not $lead.Email.contains().

New Participant
October 24, 2022

Thank you

SanfordWhiteman
New Participant
October 22, 2022

Nothing you’re trying to do with Velocity in the email body (not in a {{my.token}}) is supported. There are innumerable unexpected behaviors when attempting this, and no guarantee that something that works today will work tomorrow. In particular I can’t imagine why you wouldn’t use an actual Email Script {{my.token}} to parse the domain.

New Participant
October 22, 2022

Hi Sanford, 

 

reason is that this has to happen before my-tokens are exchanged from Marketo. 

But at the end it's the question - can you imagine why a given string is processet like expected but a string set via token is not? 
Is it maybe a question of processing order? Or maybe a question for the format/coding the token result is delivered?

SanfordWhiteman
New Participant
October 22, 2022

reason is that this has to happen before my-tokens are exchanged from Marketo.


I don’t understand what this means. Exchanged?

 


But at the end it's the question - can you imagine why a given string is processet like expected but a string set via token is not?

Because you’re expecting a certain order of processing which is not supported.