Get the address behind a link in email

Hey all
I have a problem I can't seem to work out.
One of the email systems that I have to use automatically adds the word "blocked" to any html link in an email. So for example, if you get an email from Expedia with a link to your itinerary that says "Click here for your trip details", it will change the underlying link address from "http://expedia.com/" to "blockedhttp://expedia.com".
To get around this, you have to manually copy the link, and paste it into the browser, then remove the "blocked". Kind of a hassle.
I want to script this process as a Service. I've written Services before, and have experience in AS, but I can't figure out how to do it. Parsing the link and sending to my browser isn't a problem. The problem is that I haven't found a way to get Mail to pass me the value of the LINK instead of the TEXT.
I've even tried using Automator and telling it (as a Service) "Service receives selected URLs in Any Application" - but of course it doesn't recognize "blockedhttp" as a valid URL so it gets ignored.
Mail has the right-click "copy link" function - if I could figure out how to script that, I could grab the link of the clipboard and parse it. Alas, no dice there either.
Anyone have any clever thoughts about how I can extract the link from that href in Mail, or execute the "Copy Link" function?
Message was edited by: stephen.bradley

Well, for anyone in the future who might have a situation like this to solve, here's the solution. At least, the only solution I could come up with, I'm sure a more brilliant programmer would do something different.
There seemed to be no way of grabbing the embedded link from the email text and getting it into a custom Service with a simple right-click. The suggestion to parse the file as raw source was interesting, but it would have meant parsing all of the sometimes several dozen emails I get everyday, looking for the few with links.
So, I went a different way. I wrote a script to handle the "on open location" event, and had it parse out the 'blocked' portion of the link, then fed that cleaned link back to the Finder to open in my default browser.
Save the Applescript as an application so it produced a bundle, then went into the bundle's info.plist file and set it up as the default handler for protocol 'blockedhttp' and 'blockedhttps'. It was added to LaunchServices (which OS X took care of for me). Now clicking a link formatted that way causes my AS app to be called as the handler, it does its simple little dance and passes it on.
Truth is the solution was simple, once I looked at it differently.
Hope that helps someone in the future!
on run
display dialog ¬
"This script applet will respond to webpage links beginning with:"¬
& return & return & ¬
"blockedhttp(s)://" buttons {"OK"} ¬
default button 1 with title "AKO Blockage Handler" with icon 1
tell application "Finder" to update (path to me)
end run
on open location this_url
set theLength to length of this_url
set newURL to (characters 8 through theLength) of this_url as string
tell application "Finder"
open location newURL
end tell
end open location
To make the info.plist file handle my new "protocol" I just added a couple of keys:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>BlockedURL Helper</string>
<key>CFBundleURLSchemes</key>
<array>
<string>blockedhttp</string>
<string>blockedhttps</string>
</array>
</dict>
</array>
The CFBunderURLName is just a friendly name for the protocol, and the URLSchemes defines the protocol identifier.
Message was edited by: stephen.bradley
Message was edited by: stephen.bradley

Similar Messages

  • I cant copy a youtube link to my email. i get the address, but no link.

    i just switched to firefox. i have not had this problem before. i go to youtube, highlight the link, hit ctrl and c, then go to my email, where i hit ctrl and v, but it wont come up with a hyperlink.

    This is the second time I've upgraded from FF 5 to FF 6.02 and both times I lost the ability to make desktop shortcuts by dragging the favicon to the desktop. I need the feature.
    Also, I'm sick of getting bugged to upgrade from FF 5 to 6. I'm not upgrading my other computers until this problem is fixed.
    I'm on a recent Dell PC with 4GB RAM, 1TB HD with lots of space, fully upgraded Vista Business, no extensions, only common business programs.
    Jim
    Silicon Valley, CA

  • When I attempt to connect to iCloud I get the error message: Apple id's email address cannot be verified.  There is nothing wrong with my apple id and I do not want to change it.Any suggestions?

    When I attempt to connect to iCloud I get the error message: Apple id's email address cannot be verified.  There is nothing wrong with my apple id and I do not want to change it.Any suggestions?

    Debi....
    Try "resetting" your Apple ID password >  Apple - My Apple

  • I have aperture 3.2.4 on my laptop and have the serial number, but just bought a new MAC and I can't get the Ver 3.0 link to work. Anyone know how to move it from my laptop to our new mac?

    I have aperture 3.2.4 on my laptop and have the serial number, but just bought a new MAC and I can't get the Ver 3.0 link to work. Anyone know how to move it from my laptop to our new mac?

    I am talking about the Ver 3 download link that came with the purchase email.
    That link is no longer available. Use "Migration Assistant" to copy your Applications from your old mac to the new Mac, then immediately run software update. Aperture Version 3.2 will not run on your new mac with Mavericks, you will have to Upgrade to version 3.4.5 at least - you can download this update from the Support page: Aperture 3.4.5
    Then launch Aperture and enter your registration key and try now too update from version 3.4.5 to 3.5 from the AppStore. The AppStore will change your Aperture registration to an AppStore version, so you will able to reinstall by downloading from the AppSTore in future.
    If you want transfer only Aperture and no other applications, do it manually: You will have to copy not only the application but folders from the libraries as well:
    /Applications/Aperture.app
    /Library/Application Support/Aperture/
    ~/Library/Application Support/Aperture/
    Leonie

  • I got my Macbook Air from a family member and I can't get my address book on my computer.  What do I do to get the address book on it?

    I purchased an Air Mac and can't get the address book on it.  Does anyone have any ideas on what I should do.  I have an IPhone and an IPad and they both have clouds but I don't see one on my Air Mac.

    From the link posted in TD's reply
    To unhide your purchases
    Open the Mac App Store.
    Choose Store > Sign In, then enter your Apple ID and password.
    Choose Store > View My Account.
    Click on View Hidden Purchases from the Account Information page.
    From the Hidden Purchases page, locate the app you would like to unhide.
    Click the Unhide button.
    LN

  • The address book in a new email shows only names, no addresses

    I recently added new names with their email addresses in "Address Book" - picked the Group I wanted and then clicked the + sign under Names and entered the info in the space to the right.  I had already created a mailbox for each name and had gone through Mailbox-Preferences-Rules to have emails from or to routed to the correct boxes [which it did when I clicked on "Apply" at the end of this process].  All this to show what I did prior to choosing "New Message" in Email.  When I got the blank email page, I clicked on the Address Book icon above to retrieve the address I wanted and only the names of the people I had entered were displayed, NOT their email addresses.   I then restarted the computer - still the same.  How do I get the addresses to show up???

    Solved the problem.  Guess it helps sometimes to write down problems.

  • I no longer have an internet address window - only a search window. How to I get the address window back?

    I no longer have an internet address window on my Mozilla browser -- only a (Yahoo, Google, etc.) search window.
    How to I get the address window back?

    This link shows how to restore missing toolbar items such as the address bar - https://support.mozilla.com/kb/Back+and+forward+or+other+toolbar+items+are+missing

  • I use Links alot in my web surfing, dragging the icon in the address bar to Links. I can't seem to find anywhere that allows me to search those Links.

    I use Links alot in my web surfing, dragging the icon in the address bar to Links. I can't seem to find anywhere that allows me to search those Links. I can't find a folder for them on my hard drive to search .. Help!

    You can get Firefox 3.6.16 here:
    http://www.mozilla.com/en-US/firefox/all-older.html
    http://support.mozilla.com/en-US/kb/Installing+a+previous+version+of+Firefox

  • How come I don't get the whoosh when I send an email?

    After I installed Mavericks I don't get the whoosh when I send an email.  If I restart I'll have it until the machine goes to sleep and then it'll disappear agian.

    Note:  None is not an option in all Countries and/or Regions.
    If necessary...
    Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

  • I  do not get the watching forum thread/category in emails for 2 days

    Hi Sir/Madam,
    I do not get the watching forum thread/category in emails for 2 days .
    I dont know the reason. i get other emails.
    I dont want to change my email address.
    Looking forward to your positive reply.
    Thanks and regards,
    Rajeshkumar

    still not working , i regret with the oracle service. now i am using another new email id to watch forum threads.

  • How can I get the address from a map struct?

    Hello,
    Who knows how to get the address from a map struct, and what's the meaning of the eighth argument (addr) of ufs_getpage() ?
    I developed a modular to encrypt certain files. The approach is: I�fll change the vnode's v_op pointer when opening a file which should be decoded. I make the vnode->v_op point to my own ops struct. I made a new ufs_getpage function like below:
    static int newufs_getpage(struct vnode* vp, offset_t off, size_t len,
    uint_t* protp, page_t* plarr[], size_t plsz,
    struct seg* seg, caddr_t addr, enum seg_rw rw,
    struct cred* cr)
    call old ufs_getpage(vp, off, len, protp, plarr, plsz, seg, addr, rw, cr);
    decode the page.
    After reading some source code about kernel, I know the plarr is the page which is read from the disk. But I don't know how to get the address of the page. I tried like below, but failed.
    caddr_t baseaddr;
    page_t *pp;
    pp = plarr[0];
    �c�c
    baseaddr = hat_kpm_page2va(pp, 0);
    �c�c
    I logged the baseaddr:
    cmn_err(CE_NOTE, �gbaseaddr %s�h, baseaddr);
    or
    char _buff[8];
    int _len;
    copyinstr(baseaddr, buff, 8, &len);
    cmn_err(CE_NOTE, �gbaseaddr %s�h, _buff);
    But I found the baseaddr is not what I want. Is there something wrong with my approach? What's the meaning of the eighth argument (addr) of ufs_getpage()
    By the way, is there any documents concerning to the functions such as segvn_fault�Appmapin/ppmapout except the source code?

    Hiya,
    I think the address is the faulting address in segmap.
    But why not have a look at the file event management framework in NFSv4:
    http://cvs.opensolaris.org/source/xref/on/usr/src/uts/common/fs/fem.c
    To support NFSv4 delegation, FEM provides hooks to intercept filesystem operations.
    Maybe you could use that to implement what you want? Probably safer than doing what you are doing now. Go see fem_install().
    Cheers,
    R.
    Message was edited by:
    ralphyt

  • How can I get the address book to sort by "Last" name (using v 31.3.0).

    After a computer crash, I had to load Thunderbird (v31.3.0) back into my machine running Windows 8.1, and I successfully imported my address book back up file into Thunderbird (v31.3.0).
    My problem is that I don't see an option to sort the address book by "Last" name, which was available with the version of Thunderbird I had before the crash.
    How can I get the address book to sort by "Last" name?

    In 'Address Book'
    Select address book
    'View' > 'Show name as' > 'Last/First'
    The you can sort by Name.
    Either click on 'Name' column header to change sort order,
    If reversed, then click on 'Name' column header again to reverse the order.
    Or
    'View' > 'Sort By' > choose 'Name' and 'Ascending'

  • Can't get Firefox to open a new tab as my homepage or a specific url. Alwatys get 'The address isn't valid'

    When opening a new tab, I keep getting 'The Address isn't valid'. Went through all the fixes given in previous threads, changing the url in about:config, running Firefox in safe mode (problem still exists with plugins disabled) resetting Firefox, changed newtab settings to about:home etc, restarted, deleted cookies. Nothing seems to work. Some other program seems to be overriding the Firefox settings. May be a virus. I am using the latest McAfee software.
    I once had an add-on that brought up thumbnails with a new tab but I removed that a while back.
    On the right hand side search bar of firefox I can see that Bing is one of the dropdown search engine choices not that it should make a difference but I thougth they were sometimes a bit aggresive.
    Anyhow, would love to know if there is a solution as it's making me suspicious of having an undetected visus or hijacking.

    Thanks for your relpy but I've already tried these solutions and no joy. I tried them again there just to be sure but still no good.
    In the mean time I installed a plug-in that does this for me. I used My Homepage 1.2 and it's done the business.
    Still don't know what was causing the problem. (And it wasn't a typo, I checked and copied and pasted urls from other locations...)

  • I  only get Facebook addresses when trying to compose email. How do I get hold of my other email addresses? IOS 6, iPad2

    I only get Facebook addresses when trying to compose email. How do I update my contacts to reflect other email addresses?

    Navigate to Settings, then Facebook, then Contacts OFF.

  • How do I get the address field to show (again) at the top of the page????

    I was messing around with stuff I don't understand, and managed to make the web address field disappear from the top of the page....now I've got only a page title in a gray field. Help! (please). I can't figure out how to get the address to appear again.
    I'm stuck and can't surf

    View menu...  try either "Show Toolbar" or "Customize Toolbar..."
    charlie

Maybe you are looking for

  • How to change the colour of selected item in itemrenderer

    Hello guys please tell me how to change the selected image( which is in itemrender of tilelist).so that the colour sholud be shown within  image not its outer part due to renderer. Thanks in Advance   vineet sharma

  • Can't find flex 3 component kit

    Downloaded the latest Flex 3 sdk but there's not flash-integration directory of and mxp file to install the latest component kit for Flash? Am I missing something? [flex_sdk_3.zip]\frameworks\flash-integration\

  • Importing field values in iPhoto 08

    Hi, I've been trying out Portfolio to organize my images but have come to the conclusion that it is too much software for my needs. The thing is that I now have about 300 images with keywords and other info now sitting in Portfolio. One solution woul

  • Applications won't launch in Yosemite OS X

    After installing Yosemite OS X some applications such as Photoshop CS6, Firefox won't launch. The icons of the applications keep bounching in the dock and after a while it will stop bounching  with the message "Application Not Responding". Seems like

  • Points Hunter..

    Hi, I think Amruth Kumar and Chandra Prakash are Same. Table of t-codes About CTS Difference between MACRO & SUBROUTINE how to caputre report output into an internal table? Need transaction code How to debug a program running in background?