Share a link via URL scheme to Telegram - html

I want to share a link via URL scheme for Telegram.
I have created this:
tg://msg?text = www.example.com?t=12
The link, opens telegram but nothing else happens.
I have used the same code for Viber, and it works:
viber://forward?text = www.example.com?t=12
And it opens a new message in Viber with this text:
www.example.com
In the other words, it cuts my URL.
Any ideas?

You can also use telegram.me share link which falls back to webogram if a telegram app is not installed on the device.
https://telegram.me/share/url?url=<URL>&text=<TEXT>

This works with me:
tg://msg?text=Mi_mensaje&to=+1555999

You have the following options for a URL...
https://t.me/share/url?url={url}&text={text}
https://telegram.me/share/url?url={url}&text={text}
tg://msg_url?url={url}&text={text}
In case you want to confirm, here is the official API source: Core.Telegram.org: Widgets -> Sharing Button.
If you are interested in watching a project that keeps track of these URLs, then check us out!: https://github.com/bradvin/social-share-urls#telegramme

You can use the link telegram.me which will provide a preview page with an alert requesting to open the link in the application.
https://telegram.me/share/url?url=<URL>&text=<TEXT>
The second option is calling the application link directly:
tg://msg_url?url=<url>&text=<encoded-text>
I particularly prefer the second option, which also works on desktop applications.

For Telegram share:
Objective C:
if([UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"tg://msg?text=test"]){
[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tg://msg?text=test"]
}else{
//App not installed.
}
Swift 3.0:
let urlString = "tg://msg?text=test"
let tgUrl = URL.init(string:urlString.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)!)
if UIApplication.shared.canOpenURL(tgUrl!)
{
UIApplication.shared.openURL(tgUrl!)
}else
{
//App not installed.
}
If you have used canOpenURL, then need to add in info.plist
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tg</string>
</array>

PHP
Link
JavaScript
<script>TEXT="any text or url";</script>
<a onclick="window.location='tg://msg?text='+encodeURIComponent(TEXT);">Link</a>

Telegram
with this we can open xdg of telegram and if we select contact , by default sending text will come in message field.

Maybe you use localhost therefore it does not show share. try it in live host

To check if the Telegram is installed you can do the following (borrowed from the Whatsapp sharer module of ShareKit):
BOOL isTelegramInstalled = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"tg://msg?text=test"]];
iOS checks if there's any app installed which can handle the tg:// scheme, which is Telegram.

Try using tg://share:
Link

Just tested, this way it works both opening telegram app or browser in case it's not installed:
let webURL = NSURL(string: "https://t.me/<YOUR ID>")!
UIApplication.shared.open(webURL as URL)

Your have two problems:
On one hand you are using the wrong scheme for sharing URLs, the correct one is msg_url;
On the other hand you are trying to share a URL with parameters. You need to encode your ? in order to make it work. The percent code is %3F
Extra Tip: Also if you want it to be a link once shared you should include the HTTPS:// encoded of course.
Try this and you'll see it works fine: tg://msg_url?url=https%3A%2F%2Fwww.example.com%3Ft=12

If you want to open chat with bot or people, just write this simple code
<a href="https://t.me/targetedusername">

You should stop using the protocol for the desktop applications because it does not work on the evolving web: it does not work on Web apps, ChromeOS, or some mobile devices.
Always use the NEW way: https://t.me because it will open the Telegram DESKTOP app in Windows\Linux\Mac IF THE USER WANTS\HAS it, otherwise it will open the WEB page\web app which is THE WAY.
https://web.telegram.org/k
https://web.telegram.org/z
Telegram has TWO web apps that have been building out for the past year!
Both are great, adding TONs of parity, and have different approaches.

Related

Iframe in Chrome error: Failed to read 'localStorage' from 'Window': Access denied for this document

I have a web app which uses localStorage. Now we want to embed this web app on other (third-party) sites via iframe. We want to provide an iframe embed similar to youtube so that other websites can embed our web app in an iframe. Functionally it is the same as if it wouldn't be embedded. But it does not work. Chrome prints the error message:
Uncaught SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
I just do the following check (in the iframe):
if (typeof window.localStorage !== 'undefined') {
// SETUP SESSION, AUHT, LOCALE, SETTINGS ETC
} else {
// PROVIDE FEEDBACK TO THE USER
}
I checked my security settings in Chrome like described in another Stackoverflow Thread but it doesn't work. Is there any change to make embedding possible without the need of adjusting (default) security settings of most modern browsers?
To give more information, we use Ember-CLI for our web app and turned on CSP (more info about the Ember-CLI CSP). Could CSP cause our web app to throw security errors?
Under Chrome's Settings > Privacy > Content Settings, you have the cookie setting set to "Block sites from setting any data".
This checkbox is what is causing the exception.
According to this
This exception is thrown when the "Block third-party cookies and site data" checkbox is set in Content Settings.
To find the setting, open Chrome settings, type "third" in the search box, click the Content Settings button, and view the fourth item under Cookies.
On the following URL: chrome://settings/content/cookies uncheck "Block third-party cookies".
If you're using incognito mode, make sure you turn off "Block third-party cookies".
Open a new tab in any incognito window, and turn off the option:
localStorage is per domain, per protocol. If you are trying to access localStorage from a standalone file, i.e. with file:/// protocol, there is no domain per se. Hence browsers currently would complain that your document does not have access to localStorage. If you put your file in a web server (e.g. deploy in Tomcat) and access it from localhost, you will be able to access localStorage.
I ran into this problem in my phone, I couldn't open a certain site with chrome.
It took me some time to find the cookies on my phone, when I found it, I saw that my cookies was blocked.
go to your Settings --> Site settings --> Cookies
and allow the site to save and read cookie data, make sure that you don't block third-party cookies!
I hope this helps you.
I checked all the answers but ended up not finding anything. Then I realized what browser I'm using. If you're using Brave (Chromium Based), you will get this error if your shield is up. Try lowering your shield.
A more secure way of doing this in Chrome would be to allow only the site(s) that you trust:
Chrome
-> "Settings"
-> "Show advanced settings..."
-> "Privacy"
-> "Content settings..."
-> "Manage exceptions..."
-> (add a pattern such as [*.]microsoft.com)
-> be sure to hit enter
-> "Done"
-> "Done"
If disable block third-party cookies is not an option, you can use try...catch:
try {
// SETUP SESSION, AUHT, LOCALE, SETTINGS ETC
} catch(err) {
// PROVIDE FEEDBACK TO THE USER
}
As has been pointed out in the comments, localstorage is single origin only -- the origin of the page. Attempting to access the page's localstorage from an iframe loaded from a different origin will result in an error.
The best you can do is hack it with XDM via the postMessage API. This library purports to do the heavy lifting for you, but I haven't tried it. However, I would make sure you're aware of IE's terrible support for XDM before going down this route.
imho it has nothing to do with CSP settings on your ember cli app but to do with browser settings.
Some browsers (Chrome) block localStorage content loaded into an iframe.
We too are facing a similar situation for our Ember App,were we have an ember app and a plugin which loads on 3rd party websites, the user token loaded into the iframe gets blocked in Chrom,we are experimenting with some solutions, will keep this thread posted as to how it goes.
To get rid of this warning - under Chrome's Settings -> Privacy -> Content settings, you have to clear the "Block third-party cookies and site data" option
Secure way of doing this in Chrome top right, click on eye logo and allow the site you are on to use third-party cookies:
Check this image if you can't find the eye logo
Clear Cookie
Chrome->setting->privacy and Policy->Sites that can never use cookies In turnremove cookie for local storage.
For all others like me who search for a Javascript solution/fix:
var storageSupported = false;
try
{
storageSupported = (window.localStorage && true);
}
catch (e) {}
if (storageSupported)
{
// your code
}
Credits: https://github.com/zoomsphere/ngx-store/issues/91

Dynamic Link Actions in mailchimp

I need to do dynamic link opening based on each of 3 cases. How do I write this into a link ?
Case 1: user is on desktop or Android. Send user to website link with
reference to content example.com/content/123
Case 2: user is on
iOS app is not installed. Send to App Download, post download open
content article that user tapped on
Case 3: user is on iOS app is
installed. Open app with activity link and link to that activity in
the app myapp://content/123
Any ideas how to write this into an HTML source that I can add to email? On click it will have to figure out what it wants to do.
Here is what the source looks like in mailchimp email template per content item:
<span>A brief funny description about this place, in one or two phrases...
Read More
</span>
Any help is greatly appreciated.
You are looking for the concept of deep linking. I can help you with 2 of your cases
First I'll explain how I would attempt to make this work. This sample will open the Facebook app and navigate to the Wikipedia page. You can try this out by opening this link from your Android or iOS device.
Instead of having the direct link in the email itself, I'd use one link that would then, on the server's side, determine the action to take.
In your email template, do this
<span>A brief funny description about this place, in one or two phrases...
Read More
</span>
This should then take the user to a script named 'my_server_script.php' (my example is PHP, but you can achieve this in any language).
In this script, you can then check the User Agent by using PHP's $_SERVER['HTTP_USER_AGENT']. This will give you something like Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418 (KHTML, like Gecko) Safari/417.9.3. Then by parsing this string, you can determine the user's OS and take an action based on that. Please do note that User Agent strings can be modified and is not always 100%, but it should be more than enough for your use.
Once you have determined the action to take, you could redirect the user to the app by sending them to the deeplink.
Here is PHP code I tested on Android earlier, this should open the Facebook app and take you to the Wikipedia page. As far as I know, it should work on iOS as well.
<?php
// Set App deeplink
$app_url = 'fb://profile/33138223345';
// Try to redirect the device to the URL
header('Location: ' . $app_url);
?>
I don't have a solution for detecting if the app is installed, but if you do find a solution for
that, you should be able to redirect them to the appropriate app store using the code below
<?php
// iTunes link
$app_install_link = 'https://itunes.apple.com/za/app/facebook/id284882215?mt=8';
// Then redirect the user to the app store location
header('Location: ' . $app_install_link);
?>
If you determine they should be sent to the desktop version, simply do
<?php
// Browser link
$link = 'https://example.com/content/123';
header('Location: ' . $link );
?>
This is personally how I would make this work since you won't have the capability in the email itself to check what device you are on and modify the link based on that.
You should however still be able to use the deeplink fb://profile/33138223345 by doing
<span>A brief funny description about this place, in one or two phrases...
Read More
</span>
and that should open the Facebook app on iOS and Android.
Hope this helped a bit!

I have a public URL for an iCloud file, how can I get the DIRECT link to download in iOS?

I am able to generate public URLs for iCloud files. e.g. https://www.icloud.com/documents/dl/?p=3&t=BAKsXkcDP-p8sdTS8NgBLWRQxE281oe4hogA
Accessing such a URL from a browser, I see a landing page, and shorty afterwards the file downloads automatically. Fine.
However, I want to be able to download this file from my iOS app (with NSURLConnection). How can I do this? Maybe...
a) process the html headers to somehow determine the direct URL?
b) intercept the redirect/refresh that triggers the download on a browser?
c) somehow imitate a browser in order to trigger a download?
Thanks
PS. please give me the idiot's answer- I'm clueless about html etc.
Here is the html response I'm getting for the indirect URL above:
var SC_benchmarkPreloadEvents={headStart:new Date().getTime()}; -->iCloud - Loading ...window.SC=window.SC||{MODULE_INFO:{},LAZY_INSTANTIATION:{}};SC.buildMode="production";
SC.buildNumber="1FCS22.32292";SC.buildLocale="en-us";String.preferredLanguage="en-us";window.SC=window.SC||{MODULE_INFO:{},LAZY_INSTANTIATION:{}};SC._detectBrowser=function(userAgent,language){var version,webkitVersion,browser={};
userAgent=(userAgent||navigator.userAgent).toLowerCase();language=language||navigator.language||navigator.browserLanguage;
version=browser.version=(userAgent.match(/.*(?:rv|chrome|webkit|opera|ie)/: ([ );]|$)/)||[])[1];
webkitVersion=(userAgent.match(/webkit/(.+?) /)||[])[1];browser.windows=browser.isWindows=!!/windows/.test(userAgent);
browser.mac=browser.isMac=!!/macintosh/.test(userAgent)||(/mac os x/.test(userAgent)&&!/like mac os x/.test(userAgent));
browser.lion=browser.isLion=!!(/mac os x 10_7/.test(userAgent)&&!/like mac os x 10_7/.test(userAgent));
browser.iPhone=browser.isiPhone=!!/iphone/.test(userAgent);browser.iPod=browser.isiPod=!!/ipod/.test(userAgent);
browser.iPad=browser.isiPad=!!/ipad/.test(userAgent);browser.iOS=browser.isiOS=browser.iPhone||browser.iPod||browser.iPad;
browser.android=browser.isAndroid=!!/android/.test(userAgent);browser.opera=/opera/.test(userAgent)?version:0;
browser.isOpera=!!browser.opera;browser.msie=/msie/.test(userAgent)&&!browser.opera?version:0;
browser.isIE=!!browser.msie;browser.isIE8OrLower=!!(browser.msie&&parseInt(browser.msie,10)<=8);
browser.mozilla=/mozilla/.test(userAgent)&&!/(compatible|webkit|msie)/.test(userAgent)?version:0;
browser.isMozilla=!!browser.mozilla;browser.webkit=/webkit/.test(userAgent)?webkitVersion:0;
browser.isWebkit=!!browser.webkit;browser.chrome=/chrome/.test(userAgent)?version:0;
browser.isChrome=!!browser.chrome;browser.mobileSafari=/apple.*mobile/.test(userAgent)&&browser.iOS?webkitVersion:0;
browser.isMobileSafari=!!browser.mobileSafari;browser.iPadSafari=browser.iPad&&browser.isMobileSafari?webkitVersion:0;
browser.isiPadSafari=!!browser.iPadSafari;browser.iPhoneSafari=browser.iPhone&&browser.isMobileSafari?webkitVersion:0;
browser.isiPhoneSafari=!!browser.iphoneSafari;browser.iPodSafari=browser.iPod&&browser.isMobileSafari?webkitVersion:0;
browser.isiPodSafari=!!browser.iPodSafari;browser.isiOSHomeScreen=browser.isMobileSafari&&!/apple.*mobile.*safari/.test(userAgent);
browser.safari=browser.webkit&&!browser.chrome&&!browser.iOS&&!browser.android?webkitVersion:0;
browser.isSafari=!!browser.safari;browser.language=language.split("-",1)[0];browser.current=browser.msie?"msie":browser.mozilla?"mozilla":browser.chrome?"chrome":browser.safari?"safari":browser.opera?"opera":browser.mobileSafari?"mobile-safari":browser.android?"android":"unknown";
return browser};SC.browser=SC._detectBrowser();if(typeof SC_benchmarkPreloadEvents!=="undefined"){SC.benchmarkPreloadEvents=SC_benchmarkPreloadEvents;
SC_benchmarkPreloadEvents=undefined}else{SC.benchmarkPreloadEvents={headStart:new Date().getTime()}
}SC.setupBodyClassNames=function(){var el=document.body;if(!el){return}var browser,platform,shadows,borderRad,classNames,style;
browser=SC.browser.current;platform=SC.browser.windows?"windows":SC.browser.mac?"mac":"other-platform";
style=document.documentElement.style;shadows=(style.MozBoxShadow!==undefined)||(style.webkitBoxShadow!==undefined)||(style.oBoxShadow!==undefined)||(style.boxShadow!==undefined);
borderRad=(style.MozBorderRadius!==undefined)||(style.webkitBorderRadius!==undefined)||(style.oBorderRadius!==undefined)||(style.borderRadius!==undefined);
classNames=el.className?el.className.split(" "):[];if(shadows){classNames.push("box-shadow")
}if(borderRad){classNames.push("border-rad")}classNames.push(browser);if(browser==="chrome"){classNames.push("safari")
}classNames.push(platform);var ieVersion=parseInt(SC.browser.msie,10);if(ieVersion){if(ieVersion===7){classNames.push("ie7")
}else{if(ieVersion===8){classNames.push("ie8")}else{if(ieVersion===9){classNames.push("ie9")
}}}}if(SC.browser.mobileSafari){classNames.push("mobile-safari")}if("createTouch" in document){classNames.push("touch")
}el.className=classNames.join(" ")};(function(){var styles=[];if(window.devicePixelRatio==2||window.location.search.indexOf("2x")>-1){styles=["/applications/documents/download/en-us/1FCS22.32292/stylesheet#2x-packed.css"];
SC.APP_IMAGE_ASSETS=["/applications/documents/sproutcore/desktop/en-us/1FCS22.32292/stylesheet-no-repeat#2x.png","/applications/documents/coreweb/views/en-us/1FCS22.32292/stylesheet-no-repeat#2x.png","/applications/documents/sproutcore/ace/en-us/1FCS22.32292/stylesheet-no-repeat#2x.png","/applications/documents/sproutcore/ace/en-us/1FCS22.32292/stylesheet-repeat-x#2x.png","/applications/documents/sproutcore/ace/en-us/1FCS22.32292/stylesheet-repeat-y#2x.png","/applications/documents/download/en-us/1FCS22.32292/stylesheet-no-repeat#2x.png","/applications/documents/download/en-us/1FCS22.32292/stylesheet-repeat-x#2x.png"]
}else{styles=["/applications/documents/download/en-us/1FCS22.32292/stylesheet-packed.css"];
SC.APP_IMAGE_ASSETS=["/applications/documents/sproutcore/desktop/en-us/1FCS22.32292/stylesheet-no-repeat.png","/applications/documents/coreweb/views/en-us/1FCS22.32292/stylesheet-no-repeat.png","/applications/documents/sproutcore/ace/en-us/1FCS22.32292/stylesheet-no-repeat.png","/applications/documents/sproutcore/ace/en-us/1FCS22.32292/stylesheet-repeat-x.png","/applications/documents/sproutcore/ace/en-us/1FCS22.32292/stylesheet-repeat-y.png","/applications/documents/download/en-us/1FCS22.32292/stylesheet-no-repeat.png","/applications/documents/download/en-us/1FCS22.32292/stylesheet-repeat-x.png"]
}var head=document.getElementsByTagName("head")[0],len=styles.length,idx,css;for(idx=0;
idxSC.benchmarkPreloadEvents.headEnd=new Date().getTime();SC.benchmarkPreloadEvents.bodyStart=new Date().getTime();if(SC.setupBodyClassNames){SC.setupBodyClassNames()};SC.benchmarkPreloadEvents.bodyEnd=new Date().getTime();
As of July 2012, the following seems to work. But there's no guarantee that apple won't change their scheme for generating these, and it's possible that they would regard this as a private API and reject your app. So use at your own risk.
The URL has two important parameters, p and t. The first seems to identify a server, while the second identifies the actual file. The direct download link is made by plugging these values into this URL:
https://p[p]-ubiquityws.icloud.com/ws/file/[t]
Looking at your example:
https://www.icloud.com/documents/dl/?p=3&t=BAKsXkcDP-p8sdTS8NgBLWRQxE281oe4hogA
p is 3, and t is BAKsXkcDP-p8sdTS8NgBLWRQxE281oe4hogA. So your direct download link would be
https://p3-ubiquityws.icloud.com/ws/file/BAKsXkcDP-p8sdTS8NgBLWRQxE281oe4hogA
Whenever I've published a link to iCloud, p has been 01; so it's possible that you might need to zero-pad your value in which case your URL would be
https://p03-ubiquityws.icloud.com/ws/file/BAKsXkcDP-p8sdTS8NgBLWRQxE281oe4hogA
It would be great to know whether that's necessary.
In iCloud Drive / iOS8 the links are different, but you can still get a direct link to the files.
Original link:
https://www.icloud.com/attachment?u=https%3A%2F%2Fms-eu-ams-103-prod.digitalhub.com%2FB%2FATmkKK8ju8SRwQqDoEFKJzbRsxiuAXQ3PBcJBXw1Qot9jz68TkqjiiNu%2F%24%7Bf%7D%3Fo%3DAtenENR8OcvlNq6JMa331mr-8gCreXxwcfgQ26B5gFKo%26v%3D1%26x%3D3%26a%3DBclucinSeKmFAy2GJg%26e%3D1413787013%26k%3D%24%7Buk%7D%26r%3D567CC38A-FD1B-4DE6-B11B-4166A5669E1B-1%26z%3Dhttps%253A%252F%252Fp03-content.icloud.com%253A443%26s%3DlO5SolOouS9qhYz1oIxKDoGtMpo%26hs%3DovfPXj3b9XXz9lWKChBmyNq_cug&uk=OXDCcLTETbvUcOKdJ-vTdQ&f=Testdatei.vrphoto&sz=1212622
URL decoded to be more readable:
https://www.icloud.com/attachment?u=https://ms-eu-ams-103-prod.digitalhub.com/B/ATmkKK8ju8SRwQqDoEFKJzbRsxiuAXQ3PBcJBXw1Qot9jz68TkqjiiNu/${f}?o=AtenENR8OcvlNq6JMa331mr-8gCreXxwcfgQ26B5gFKo&v=1&x=3&a=BclucinSeKmFAy2GJg&e=1413787013&k=${uk}&r=567CC38A-FD1B-4DE6-B11B-4166A5669E1B-1&z=https%3A%2F%2Fp03-content.icloud.com%3A443&s=lO5SolOouS9qhYz1oIxKDoGtMpo&hs=ovfPXj3b9XXz9lWKChBmyNq_cug&uk=OXDCcLTETbvUcOKdJ-vTdQ&f=Testdatei.vrphoto&sz=1212622
Save the text between '?u=' and '&uk=' as a NSMutableString
Save the information after 'uk=' and 'f=' as NSStrings
In the first string replace the text '${f}' with the 'f=' string and replace the text '${uk}' whith the 'uk=' string
If you need the files size for any reason, it's the number after 'sz=', but this is not needed for the final link
Voila, here is your direct link to the file:
https://ms-eu-ams-103-prod.digitalhub.com/B/ATmkKK8ju8SRwQqDoEFKJzbRsxiuAXQ3PBcJBXw1Qot9jz68TkqjiiNu/Testdatei.vrphoto?o=AtenENR8OcvlNq6JMa331mr-8gCreXxwcfgQ26B5gFKo&v=1&x=3&a=BclucinSeKmFAy2GJg&e=1413787013&k=OXDCcLTETbvUcOKdJ-vTdQ&r=567CC38A-FD1B-4DE6-B11B-4166A5669E1B-1&z=https%3A%2F%2Fp03-content.icloud.com%3A443&s=lO5SolOouS9qhYz1oIxKDoGtMpo&hs=ovfPXj3b9XXz9lWKChBmyNq_cug
It looks like the heavy lifting is done by the file referenced there:
https://www.icloud.com/applications/documents/download/en-us/1FCS22.32292/javascript-packed.js
I'd start there looking for the file name etc.

Widget object is undefined in Dashcode

I'm using Dashcode for a mobile Safari web application and from the documentation (https://developer.apple.com/library/archive/documentation/AppleApplications/Conceptual/Dashcode_UserGuide/Contents/Resources/en.lproj/MakingaWidgetwithDashcode/MakingaWidgetwithDashcode.html), it appears that I should be able to access an object called "widget".
However, when I tried, I get the error message saying that widget is undefined. I've also tried "window.widget" and it gives me the same error.
What's going on?
I'd like to make a text in my application a clickable link to open a URL using openURL (like the example given at the URL above).
You use widget.xxx to access things inside and outside you widget.
So to access curl and the Mac and get some data from Yahoo you do as follows
var yahoorate = widget.system("/usr/bin/curl 'http://download.finance.yahoo.com/d/quotes.csv?s=EUR" + interim0 + "=X&f=l1'", null).outputString;
to get a preference key value, stored in the widgets plist when you install on a mac
globalPreferenceValue = widget.preferenceForKey(null, "your-key");
i think in the question ask (below) we are checking to see if we are in a widget and then preparing a transition to the back of the widget.
if (window.widget) {
widget.prepareForTransition("ToBack");
}
this is how i set a preference so it is stored between system reboots (you use a get preference to retrieve them)
widget.setPreferenceForKey(2,"ratePrecision");
and this is how you create a link to open in a browser not the widget
<a onclick=" + "widget.openURL('http://www.wf.com/private/?ID=636');" + "><span id=company-info>click here</span></a>
These are all rel working examples from widgets i have built. Hope it helps. I found it useful to download widgets that performed similar functions to ones i wanted and then as well as installing them opening them as projects, you can import, and then you can see all the code.
Ok, this worked...hope it will help someone else...
window.location = "http://www.apple.com";

How can I embed a link button in mail to be sent to Notes clients?

I have to send an email to several hundred users. Each will have a link tailored to the recipient so I need to generate the emails in script/code - I'm no Notes developer so I can't do this in Notes; I'm using C# and I'm pulling the list out of a SQL database.
There are some constraints:
The site that the link points to uses Integrated Windows Authentication.
The sender wants the link to be a button, rather than text.
The vast majority of recipients are running Lotus Notes 7.
I've tried creating an HTML mail but have had problems:
If I use a form with a submit button and action that points to the link, Notes tries to use its internal browser which fails (because the site uses Integrated Windows Authentication).
If I use an a href tag with an img tag in it, pointing to an image on a webserver, Notes refuses to display the image - i just get the red x box, even though the tags are valid if embedded in a web page.
Anyone know how I can do this?
I finally found a method that works: embedding the image in the email itself. I found the solution here. I'll include the critical stuff here, just in case.
There are three key components to the email: the plain text version, the html version and the image, all consructed as AlternateViews:
string imagePath = #"C:\Work\images\clickhere.jpg";
AlternateView imageView = new AlternateView(imagePath, MediaTypeNames.Image.Jpeg);
imageView.ContentId = "uniqueId";
imageView.TransferEncoding = TransferEncoding.Base64;
:
//loop to generate the url and send the emails containing
AlternateView plainTextView = AlternateView.CreateAlternateViewFromString(
BuildPlainTextMessage(url), null, "text/plain");
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(
BuildHtmlMessage(url), null, "text/html");
//set up MailAddress objects called to and from
:
MailMessage mail = new MailMessage(from, to);
mail.Subject = "ACTION REQUIRED: Do this by then or else";
mail.AlternateViews.Add(plainTextView);
mail.AlternateViews.Add(htmlView);
mail.AlternateViews.Add(imageView);
//send mail using SmtpClient as normal
:
//endloop
BuildHtmlMessage(string) and BuildPlainTextMessage(string) just return strings containing the messages. BuildHtmlMessage includes this to display the image in a link to 'url':
sb.AppendLine("<div>");
sb.AppendFormat("<a href=\"{0}\" target=\"_blank\">", url);
sb.Append("<img alt=\"Click here button image\" hspace=0 src=\"cid:uniqueId\" ");
sb.Append("align=baseline border=0 >");
sb.Append("</a>");
sb.AppendLine("</div>");
Hope this is of use to someone else, sometime.
I imagine no matter what link you use (button, text), you're going to run into that same problem where the Notes client launches its internal browser. That's a preference on the Notes client, and it could be different on all machines.
I would first try a standard text link to see if it has the same behavior. Maybe if that does work for some reason, you at least can deliver a workaround.
Regarding the image issue - is the image coming from the server using Windows Authentication? Make sure the image is open to the public and doesn't require authentication to see it (test in Firefox, and if you don't get a password prompt, you're safe)
I hate to say it, but you might have to request users copy a URL from their email to a specific browser. At least you'd know that would work.
I agree with Ken on the preference for the internal browser. The image not displaying - showing a red x - might be a preference also. I don't recall if it was available in R7, but in R8 there is a preference to not show remote images automatically. It is a security feature. It could also be a proxy issue - if they would have to login to their internet proxy server to get to the internet, and your image is on the internet...
There is also this but it fires off a security warning to the user with my Notes config:
<input type='button'
onclick=document.location.href='http://server/path';
value='Click here'
id='buttonID' class='button'
xstyle='background-color:red;color:white;'/>