Generating an email from a screen

Use this board to ask questions or have discussions with other Genie users.
Post Reply
Wayne C.
Experienced User
Posts: 139
Joined: Mon Aug 16, 2010 12:04 pm
First Name: Wayne
Last Name: Colasinski
Company Name: Sofworx / Tantara Transport
Contact:

Generating an email from a screen

Post by Wayne C. »

We are trying to generate an email from by clicking on an email address displayed on a screen. We want to populate the subject with an order # also to be found on the screen. At this stage I've hardcoded something into the subject to get something going. This is what we've come up with after scouring the forums:

pui.link("mailto:"+(get("I_21_8")));pui.link("mailto:?subject=Wayne");

Oddly enough, this actually works sometimes. If it doesn't work and I click on the address again, it may display 2 emails; the first one with the "To:" and "Subject:" populated correctly and a second one with only the "Subject:" populated. We've played with this a bit and can't get it to work correctly on a consistent basis. And I've not even tried to "get" the order # yet. Could somebody help us out?
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Generating an email from a screen

Post by Scott Klement »

What you're doing is building a mailto: URI. Similar to an http:// URI, except that it invokes your e-mail client instead of invoking a web page.

You seem to have the idea correct, except that you aren't encoding the URI. There are certain characters that have special meanings ina URI, and so must be encoded (or "escaped") to prevent those special meanings. There's a javaScript function called encodeURIComponent() that is intended for that purpose.

For example:

Code: Select all

pui.link("mailto:president@whitehouse.gov?subject="+encodeURIComponent(get("I_21_8")));
Does that help?
Wayne C.
Experienced User
Posts: 139
Joined: Mon Aug 16, 2010 12:04 pm
First Name: Wayne
Last Name: Colasinski
Company Name: Sofworx / Tantara Transport
Contact:

Re: Generating an email from a screen

Post by Wayne C. »

Thanks much Scott. Here's what my final code looks like. Seems to work consistently.

pui.link("mailto:"+encodeURIComponent(get("I_21_8"))+"?subject="+encodeURIComponent(get("D_2_20")));
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests