You are viewing limited content. For full access, please sign in.

Question

Question

add javascript code in email body

asked on May 4, 2015

i need to add javascript  to email body to modify the document web link depending on if statement . how can i do that? 

0 0

Replies

replied on May 4, 2015

I do not believe JavaScript is allowed to be expressed in most email clients.

 

 

http://stackoverflow.com/questions/1088016/html-email-with-javascript

2 0
replied on May 4, 2015

Carl is right. Why are you trying to modify the URL after the user receives the email?

0 0
replied on May 4, 2015

If it helps any, here's one way to accomplish what you may be looking for if you can perform the logic before submission of email.

 

Could also perform 1 email activity after exiting the conditional statement and just use the branches to set variables to be included in the standard email.

 

0 0
replied on May 4, 2015

because in our case we are using 2 web server one inside our company to be accessed by internal users and another web server for external users . and i'm sending email with 2 links (internal link and external link). so i'm searching if i can add javascript code so it can determine if this internal user or external user so from the client side will choose the correct link for him with one link in the email .

0 0
replied on May 4, 2015

Like Carl said above, it's unlikely mail clients will let you run javascript. It's more probable it will be treated as a security risk.

You could add both links to the email. The internal one would only work inside the firewall anyway and you could label them accordingly.

Or you could look at the email address and see if there is a pattern to the internal ones vs the external ones, then have 2 separate messages. For ex, everything that ends with, say, @myDomaincom would get the email with the internal link, while everything else would get the external one.

0 0
replied on May 4, 2015

I believe it's possible to configure your DNS so that a hostname resolves differently internally than it does externally, which you can use if the rest of the URLs are the same.

0 0
replied on May 4, 2015

Miruna Babatie: i'm already using 2 links in the email. and about the other solution regarding the pattern for internal ones vs the external one , i don't think this is possible because it's the same document, i need to access it from internal or external per person .

Brian McKeever: i think i'll coordinate with our network admin to try it .

0 0
replied on May 5, 2015

To answer the question directly, you can include JavaScript as part of your HTML-formatted email by using HTML in your email (with the HTML token formatting flag) and using the script tag inside your HTML:

<script type="text/javascript">

   // Your JS here

</script>

That said, this Javascript most likely won't work in any common email client like Gmail or Outlook.

 

The amount of flexibility you can have for formatting in email bodies is unfortunately limited by the email clients themselves (or, in this particular case, it'd be "fortunately" because running Javascript in email bodies could have sizable security ramifications). I'd be very surprised if any email client allowed Javascript to be rendered at all.

All that said, there may be non-Javascript solutions that could apply to your situation, though I wanted to clarify why Javascript itself would not likely be a viable solution =)  

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.