Programming, technology, and CRM – from a Belgian programmer exiled to Missouri
  • rss
  • Home
  • Soft Gallery
    • autosvnbackup.sh
    • VBScript Snippets
  • Contact Me
  • Welcome

Scripts are usually safe

Nicolas Galler | February 24, 2011

I think I just found the most awesome warning message ever. I am going to write all my dialogs like this too now. “Deleting an account is usually safe. Are you sure you wish to delete this account?”

Scripts are usually safe

Comments
1 Comment »
Categories
Uncategorized
Comments rss Comments rss
Trackback Trackback

Cross browser “mailto” function

Nicolas Galler | February 15, 2011

Sending an email from a web page (via the user’s client) is surprisingly tricky. A mailto: url can do the trick but it has some severe length limitations. Sending it via a background script does not have any such limitation but the user does not get a chance to edit the email, record it to their Sent Items, etc. Using Outlook automation allows for the most flexibility but it has some bad implications: only works on IE, requires some pretty specific security setting (trusted site + “enable activex controls not marked as safe”).

For an intranet scenario, where we can be certain that most users will be using Outlook and IE, I came up with the following solution. It will attempt to send the mail using Outlook automation and fall back to a “mailto” method if not available (i.e. either they are using another browser / OS, or they don’t have the correct security settings). It is a CommonJS module, I have started using RequireJS for custom modules to prevent namespace clashes.

The tricky part was making sure the URL stayed short enough – if it gets over a certain length, Firefox will just ignore it altogether (other browser will truncate it). This is the job of the addUrlComponents function. I call it with the recipient, subject and body parameters until the length is exhausted, but each is limited – this way if there is a ton of recipients, rather than trying to keep them all and getting a blank email, it limits the total address length to 900 characters and saves the rest for the email itself. It’s not ideal either way but I figured this was preferable.

I went ahead and created a test page for it since the addUrlComponents function was not trivial… this also gave me a good occasion to use qunit – very, very easy to get running with that test framework.

PS – this gist thing is a great way to get syntax highlighting on the cheap hah!

Comments
No Comments »
Categories
Javascript, Programming
Comments rss Comments rss
Trackback Trackback

Categories

  • Dojo (1)
  • Experiments (4)
  • Force.com (2)
  • Interesting (1)
  • Javascript (3)
  • MSCRM (1)
  • Programming (63)
  • Rant (3)
  • Saleslogix (41)
  • Tricks (8)
  • Uncategorized (32)

Post History

  • 2011
    • January (3)
    • February (2)
    • March (1)
  • 2010
    • January (3)
    • March (3)
    • April (2)
    • August (2)
    • October (4)
    • November (1)
    • December (2)
  • 2009
    • March (2)
    • April (1)
    • May (3)
    • June (3)
    • July (1)
    • September (3)
    • October (2)
    • December (5)
  • 2008
    • January (9)
    • February (4)
    • March (9)
    • April (1)
    • May (5)
    • June (8)
    • July (1)
    • August (2)
    • September (1)
    • November (1)
    • December (3)
  • 2007
    • January (3)
    • February (7)
    • March (1)
    • April (3)
    • May (6)
    • June (2)
    • July (1)
    • August (2)
    • September (5)
    • October (3)
    • November (5)
    • December (4)
  • 2006
    • January (2)
    • September (1)
    • November (3)
    • December (4)
  • 2005
    • April (1)

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox