Jump to content
telepet

Emailing all contacts in a table

Recommended Posts

I'm in the brainstorming phase.  Members of our staff would like to send emails out to our clients via their email application of choice-- like Outlook, etc.  I have a table of 20-400 clients that includes email address information.  Any ideas on how I can get those email addresses inside a "To:" field and send out an email?  I'm open to exploring Caspio doing this for me but I understand that might not be possible due to inherent anti-spamming design.  I'm also concerned with data usage in Caspio.

 

Note:

I have wondered about using Javascript to copy email to the system clipboard but this doesn't see like good practice, and I'm only a novice JS user at this point.  That said, this post got me thinking more on that:

 

<button id="demo" onclick="copyToClipboard(document.getElementById('demo').innerHTML)">This is what I want to copy</button>

<script>
  function copyToClipboard(text) {
    window.prompt("Copy to clipboard: Ctrl+C, Enter", text);
  }
</script>

 

Share this post


Link to post
Share on other sites

Thanks for the suggestion.  Zapier looks wonderful, especially the Mail Chimp integration.  Unfortunately, I'm not able to allow third party providers access to the data I have inside of Caspio.  

 

I'm experimenting with creating a View that contains just one column: emails of clients that are active.  I don't label the emails, and so the final output is a simple list of emails.  I adjusted the above code, replacing This is what I want to copy with a the data source field for client emails, so:

<button id="demo" onclick="copyToClipboard(document.getElementById('demo').innerHTML)">@field:CLIENT_EMAIL</button>

<script>
  function copyToClipboard(text) {
    window.prompt("Copy to clipboard: Ctrl+C, Enter", text);
  }
</script>

What this does is place a button underneath each email and allows me to copy the given email one at a time.  So, now I need to figure out a way to collect all the emails, concatenate them with ";" and paste to the system clipboard...  

 

The search is ongoing.  Thanks again for your advice on Zapier.  

 

Share this post


Link to post
Share on other sites

There are some buggy ways to prepopulate the user's email program with a list of emails. One bug that I don't like is the opening of a new tab as a side-effect. Another is call to location.href with a mailto: link getting served over http, causing a mixed contect warning. There is also the window prompt you linked to, which has a 2,000 character limit.

Since you have fewer than 999 addresses in the data set you want to use, you won't run into the 999 record per page Caspio limit, so I suggest the following, adapted from the second response to the same SO thread you linked:

In your datapage footer, add the following code

<p id="emailCount"></p>

<textarea id="emailOutput" style="width: 500px; height: 200px;"></textarea>

<p>
<button class="js-textareacopybtn">Copy Emails to clipboard</button>
</p>

<SCRIPT LANGUAGE="JavaScript">
var elems = document.getElementsByTagName("td");
var copiedEmails = [];
var numEmails = 0;
for (var i=0, m=elems.length; i<m; i++) {
if (elems[i].innerText.includes("@"))  {
copiedEmails.push(elems[i].innerText);
numEmails += 1;
}
}
var joinedEmails = copiedEmails.join("; ");
document.getElementById("emailOutput").innerHTML= joinedEmails;
document.getElementById("emailCount").innerHTML= "Found " + numEmails + " emails.";
</script>

<script>
var copyTextareaBtn = document.querySelector('.js-textareacopybtn');

copyTextareaBtn.addEventListener('click', function(event) {
  var copyTextarea = document.getElementById("emailOutput");
  copyTextarea.select();

  try {
    var successful = document.execCommand('copy');
    var msg = successful ? 'successful' : 'unsuccessful';
    console.log('Copying text command was ' + msg);
  } catch (err) {
    console.log('Oops, unable to copy');
  }
});
</script>

 

Which searches for strings containing an "@" character, adds each to an array, then joins the array with "; " for better pasting into an email client. It also displays a count of addresses found:

i7Q78VH.png

 

Share this post


Link to post
Share on other sites

@aam82: Brilliant!  I also didn't realize Caspio could do more than 250 records per page, so this work-around should work well for my purposes.  Wish this form allowed me to give you points or something.  I'll hit the "♥ Like This" button.  Thank you!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...