How to add {if} statements to emails?

Hi,

First: I am trying to understand if there is a way to apply an "if" "then" statement regarding anything after @123.com with emails. For example, IF John.Smith**@company123.com** THEN insert/add Company123 (or assign a variable if a company has multiple emails under their umbrella it would still assign it to Company123). I am essentially trying to reference/associate specific emails to specific company names.

Second: How can I apply the {if} {else} formula when entering multiple emails into an email field and have them added separately vs throwing them all in at once? I want them to be recognized as separate emails vs being inserted as one block (If I insert them all at once it'll assume it as one email block, in which case I have to manually copy/paste).

E.g. If I have a list of emails (john.smith@123.com, jane.johnson@abc.com, bill.murray@321.com), I want it to add them each individually, after each comma (or specified character). I currently am using this regex below using the {key:tab} {key:shift-tab} in between each extraction but it's conditional upon having 3 emails vs 1, 2, or 4+. I'd like it to be dynamic and look ahead or end/stop, depending on if there is 1 or more emails in the list.

Let me know if you need any clarification.

Thanks,
Josh

To your first question, yes the {if} command allows you to implement conditional logic like this. You can learn more here:

To the second, you'll want to use the {repeat} command to iterate over your list of emails. It will allow you to carry out some actions (like the {key} command) for each email. You can learn more here:

Thanks @scott! I've been reviewing {if} and {repeat} commands, which are great.

Can you provide an example of how to implement {if} and {repeat} command with the {key:} command (if applicable) and how they can be utilized together? I've been trying to experiment but have been unsuccessful. On a learning curve.

I want to extract the emails to the "To:" field and have it be dynamic (if "comma" or "space" keep extracting/adding emails, otherwise end/stop). In some cases have 1 email to send and others have 3 or more. As mentioned above, I've been able to successfully add emails separately (including tab/shift keys) but it's conditional upon having X amount of emails (E.g. { =extractregex({site: text}, "contact: (.+)[^,]") } { key: tab } { key: shift-tab } { =extractregex({site: text}, "contact: [^ ] ([^, ].+)")* } { key:tab } ......)

Emails separated

Emails together

I've attempted the {repeat} command but haven't been able to properly implement it in this case scenario yet.

At a high level you would have something like this:

Define some sample text for testing purposes in this example (this comes from the site command in your case):

{sample_page_text="contact: foo@example.com, bar@example.com"}

Get a string containing the emails from the page text:

{emails=extractregex(sample_page_text, "contact: (.+)") }

Debug emails: {=emails}

Convert that string into a list of emails (assumes each email is separated by a comma and a space):

{emails_list=split(emails, ", ")}

Debug emails list: {=emails_list}

Now we can use repeat to iterate over that list inserting them and using keypresses after each one:

{repeat: for email in emails_list}{=email}{key:enter}{key:tab}{endrepeat}

@scott

Thanks! That worked perfectly and really helped me better understand a few basics.

Regarding my First question, I've figured out the IF statement to match exact emails, however, I am trying to figure out how to apply the IF contains/includes @123.com (or a search for multiple emails associated with one company) THEN Company 123 ELSEIF (Ideally to keep searching until a match).

{ email=("@123.com") } { companyEmail=extractregex({site: text}, "Email: (.+)") } { if: companyEmail == contains(email, "@123.com") } Company 123 { else } XYZ { endif }

It's not clear to me what you are trying to do here.

contains(haystack, needle) returns yes/no depending on whether the second string is in the first. You seem to be comparing that to another string which isn't something that is going to provide a meaningful result.

Maybe you wanted: {if: contains(companyEmail, "@123.com")}...

Thank you for that clarification regarding the "contains" function. I see now the issue I was creating. I definitely wasn't receiving the correct result before.

I assume if I was to create a large list for matching I would just continue to add the same formula (while changing the associated emails and then doing the statements {elseif...@ABC.com} Company ABC {elseif...@XYZ.com} Company XYZ {else} No Return {endif}

**I've answered my question from above.

@scott

Is there a way to match multiple keywords to an IF statement? For example, IF it contains Dog, Cat, Zebra, Then, Yes. Where it must match all the keywords else no return. As I understand it, contains() needs two parameters (or as few as possible?). {if: contains(Name, "John")Smith{else}{endif}, And
it doesn't work if it's more than that since it doesn't meet the logic.

Thanks,
Josh

You can combine items with the and or or operators.

For example:

{text="I like one, three, four, seven"}

{if: contains(text, "one") and contains(text, "three") and contains(text, "seven")}
You like all three odd numbers
{endif}

{if: contains(text, "one") or contains(text, "three") or contains(text, "seven")}
You like at least one of the three odd numbers
{endif}

@scott

Thank you again for the meeting today. It was helpful to clarify the Selector tool. Although SalesForce made it difficult to identify a few items for the Selector, it provided me additional insight into its functionality and use case.

I look forward to the future releases and growth of Text Blaze.