Opening Outlook by JavaScript in Firefox - javascript

I want to open Outlook from Javascript, it's for an internal application, nothing that will ever hit the web. The customer is using IE and Firefox and Outlook will be installed, security is not an issue.
"mailto:" just isn't sufficient in this case, since the requirement is that I need to attach a file to the mail, it seems that this cannot be done by using "mailto:" (found some old-ish forum entries, but nothing of what I tried worked and it seems that the mailto URL scheme doesn't officially support it).
But, in IE I can use ActiveX:
var outlookApp = new ActiveXObject("Outlook.Application");
and then I can mess around with it, add a body, add attachments and so on, perfect.
Is something like this possible in any way in Firefox?
What I already knew was that tiddlywiki does some extraordinary things, in that it can save itself somehow on the harddisk. So I looked at the source and found this:
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
Which, as I understand gives the Script access to the Browser API/XPConnect/XPCOM. But now I'm stuck. How would I actually open an Outlook object? Would this even be a working approach? I'm not sure. Maybe any other ideas? Any advice would be appreciated.
Update:
ok, after some reading I think I can answer one of my questions with: No, this approach won't work, since the Mozilla API that's implementing XPCOM doesn't support anything like opening an external program.
Still leaves the question: Any other ideas?

Answering my own question with this: Ignore the spec, it's a bad idea.
It could be solved with an ActiveX Plugin in Firefox, but actually it's far better to just not do something like that because of security issues, even if it is only an internal application. Some browser settings need to be changed to get something like that to work, which is risky. And finally, the spec contained a not-use-case here: "upon click of a button, open outlook to send an attached file via email". The stupid thing is, that there's actually nobody whom the employees would be allowed to send the file to, apart from other employees which can access the file in the internal network, so it's far easier (and can also be securily implemented) to just send a link to the file.

Related

Unique DeviceID on Javascript Web Application(Angular, React, ...)

I have a specific need which is giving me some hard time. The basic requirement is: We need to Uniquely Identify the Device(can be a PC, Mac, Tablet, Phone) via one ID, just like an IMEI... This is needed due to some Licensing restrictions of some applications.
The challenge: We are running a Angular and the browser makes it nearly impossible to uniquely identify the device. As we are on the Browser sandbox, I have no chance to get something like a Mac address or anything that would be a good start in defining a unique ID.
What we tried so far:
MediaDeviceInfo.deviceId: https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo/deviceId
In one hand, on the first tests I made on my Chrome, it came empty and additionally it is not supported on Safari...
Valve´s FingerprintJS2: https://valve.github.io/fingerprintjs2/
At a first sight we think we hit the Jackpot as it properly generated the same ID, even if I called it from an Anonymous window! But, It still generates another ID for a different browser...
Basically It works by enumerating all browser capabilities(at least the ones accessible) and then by creating a hash of that... The Issue: If you have devices with exactly same configurations, they will have the same ID! I tried that on 2 iPhones that have the same config and were even bought on same day! :-)
Creating UID and saving on Localstorage: create a UID (How to generate UUID in angular 6) and store it on Local Storage. Some issues on our way:
If I open an Anonymous window, of course that the LocalStorage would be not there, meaning that I would get a new "UUID"
Besides that, we have some individual angular applications and they would need to share the local storage, which is not possible to do due to the SameOrigin security Limitation. We could overcome it using an iFrame and the PostMessage (https://levelup.gitconnected.com/share-localstorage-sessionstorage-between-different-domains-eb07581e9384). There are actuyll some NPM packages doing that as this one: https://github.com/ofirdagan/cross-domain-local-storage. Being honest, we do not like much the idea of create a "cross-domain-local-storage"...
I am aware that this problem has no easy solution, but I wanted to ask here if Someone faced a situation like this and how did they solve it. Of course if I would be able to run out of the browser sandbox having direct Access to device Information such as MAC address, IMEI or anything like that, it would be easy, but as mentioned, the browser sandbox is restrictive...
Ideas?
Thanks in advance!!!
Pedro
I'm going to refer you to an answer I wrote back in 2018 which is still pretty much the same now: how can I get a unique device ID in javascript?
The short answer is: you can't, really.
You won't be able to get anything that uniquely identifies a device across all browsers and incognito vs regular. As you've found, you can get close, but it isn't a sure thing.
The best you can do is combine a couple of techniques together (like the fingerprint + stored UID) and it'll probably get 99% of cases, but you won't be able to get them all for sure.

Javascript that Creates an Outlook Appointment - Browser Issue

I was looking into a script embedded in a webpage that creates an Outlook appointment and opens it. I tested a sample appointment shared by Brian White: http://www.winscripter.com/WSH/MSOffice/90.aspx
and embedded it in a sample web page, but here are two problems:
The script works only in IE and not in any other browser.
IE issues a security message about an ActiveX control and asks if to enable it.
Do you have any idea how to make it work in all browsers and not to scare users with the ActiveX warning?
Thank you in advance!
The script you've linked to works by creating an instance of the Outlook ActiveX control. As such, no, there's no way to make this work in browsers that don't support ActiveX, which is effectively all of them except Internet Explorer.
As for not scaring the users with the ActiveX dialog box, that's not in your hands. The warning message is a security feature, part of the browser itself, and can only be disabled by changing the browser's settings - which isn't something you can do through code, for obvious reasons!
If it's appropriate to your situation, rather than do this through client-side javascript your could instead use Exchange Web Services on the server-side. This comes with its own set of limitations and things to be aware of, namely (a) it's obviously impossible to open Outlook with this method, and (b) on the server-side you'd require access to the Exchange server and would need to know the username/password of an Exchange user with permission to write to the relevant calendar (which is only going to happen if we're talking about a corporate environment).
Although I realize it is an old post, I wanted to offer another approach.
I notice your question refers specifically to OUTLOOK appointments, but what about using "iCalendar"?
{http://en.wikipedia.org/wiki/ICalendar}
This could offer a wider solution. Also, a page could offer two alternative icons.
One for Outlook, another one using iCalendar, and let the user choose which one to use.
Hope this helps. Cheers.
Marcelo F.

IE settings through Javascript or jquery

Is there any possibility to set the Internet Explorer settings by running Javascript file..?
I want to set the following settings in IE through javascript/Jquery
Go to, ‘Tools’ -> ’Internet options’.
Under ‘General’ tab, click the ‘Settings’ button in the ‘Browsing History’ section.
Choose the radio button "Every time I visit the webpage".
Click ‘OK’ and restart the IE.
This is not possible - it'd be a bit of a security hole if sites were able to do this...
Firstly, the short answer is no: You can't do what you're asking for.
Javascript within the browser is heavily restricted to only being able to access resources for the actual page being viewed. This is an important security feature.
You cannot access other pages or other tabs. You cannot access parts of the browser UI outside of the page itself. You cannot run external programs.
Even if you could, the way you've described it wouldn't work anyway: The settings page you've described is specific to one particular version of IE. So your hypothetical program wouldn't work in any other browser or even any other version of IE.
However, more importantly, you need to ask yourself why you're asking for this.
The thing is that you're trying to solve a problem with your site. You've found something that resolves it, and you've asked a question about how to automate that. But you need to work backward a bit -- stop trying to work out how to automate this particular solution: you need to ask yourself whether there might be a different way of solving the original problem, which could be automated.
The fact is this: the config setting you're trying to change is for handling how the browser deals with caching of files. There are ways of changing the behaviour of caching that can be scripted by your site. You might want to look at questions like this one for example.
The lesson here is this: Don't simply ask how to do something; explain why you're trying to do it as well. There might be an alternative solution that's better than the one you've thought of.
No, it's not possible to do using JavaScript.
This is not what Javascript designed to do. There is only a way to read browser setting from JS - using signed scripts.

Is it possible to remember the filename from a fileupload field and then later launch that file via javascript?

I have a HTML file upload field from which I'm reading the file name of the file that the user specifies. The actual contents of the file is never uploaded.
At a later stage, is it possible to construct a link using this file name information so that if the user clicks on this link, the original file is launched into a new browser window? If not, what are the reason for disallowing this behaviour?
The purpose of such a feature is to store links to documents that are available on a mapped local drive or a network share.
Most likely, no.
T.J.'s Crowder answer is correct but do note that on virtually all modern browsers that will work only if the webpage you are viewing (with the input type=file) is itself a file:///.
From your question it appears to be some kind of internal company website, which most likely will have its own web server.
You'll notice that in newer web browsers your client-side code will not actually be able to read the complete pathname of a file chosen by a user. That's a security measure. IE8 provides you with some sort of obviously fake directory name, while Firefox and the Webkit browsers just strip off everything other than the file name.
Thus, I don't think you'll be able to do what you want, at all.
edit: info from msdn: http://msdn.microsoft.com/en-us/library/ms535128%28VS.85%29.aspx
New answer
Since Andreas pointed out (quite kindly!) that my old answer (below), while correct, was almost certainly useless, I thought I'd take another swing at it with something I only learned about a few days ago: The new File API from the W3C.
You won't be able to make much use of this now (except on Firefox 3.6 or above), but before too long it'll find its way into modern browsers. It actually gives you access to local files, as long as the user has explicitly selected the file for you (via an input type="file" element). You still can't see their paths, but you can open and read them from the browser (yes, really). So you could open a new window, open the file, and write the contents to the new window. Whether that will really do what you want is another question (you'll have fun writing binary files to a new window, for instance, even though the File API lets you read them just fine), but hey, it's there.
Old answer
(Although you can do the below, Andreas points out that it won't work on just about any browser unless the page the link is in is also served via a file:// URL. So, not much use then.)
You should be able to use a file:// URL for that, e.g., c:\test.txt becomes file:///C:/test.txt. Then the link just uses the URL and the target="_new" attribute telling the browser to open a new window/tab, e.g.:
<a href='file:///C:/test.txt' target='_new'>link to test.txt</a>

Html file upload preview by Javascript

I want to show a PREVIEW kind of thing for an post , so took details by JS
but problem comes when it comes to <input type="file" , it's not giving full path to the file
Ex:
if I do
$("#image").val();
it only give "Sunset.jpg" not C:\Documents and Settings\All Users....\Sunset.jpg
any idea how to get that detail value?
Although, as others have already pointed out, you cannot learn the full path to the file in JavaScript, perhaps a completely different approach to the problem might still work for you.
You could upload the photo automatically as soon as the visitor has picked it (the behavior you see in GMail, among other applications), so it's residing on your server even as the visitor continues interacting with your page. At that point, showing a preview is as simple as serving one yourself from your own (now server-side) copy of the image.
This if for security reasons, so you cannot read files from the users system using JavaScript.
If you happen find a workaround, there will probably be security patches released by browser vendors sooner rather than later. I know because in earlier versions if IE, it was possible to read the full path and hence display a preview, at least if the file was an image. I used that in a CMS UI, but of course that nifty feature was ruined by an IE service release :-/
In general the file upload control is somewhat of a "black box" for security reasons. You have only very limited access to scripting and styling it. This is so you can't snoop or upload files without the user knowing, or so you cannot trick the user into uploading files with a deceptive interface.
This is now possible as of Firefox 3.6
https://developer.mozilla.org/en/DOM/FileList
Though the code they show does not seem to work in Chrome, so I'm guessing even the HTML5 JavaScript API for things like this has yet to be standardized.
This is a security feature. You cannot change or get the entire path in secure browsers, so what you want to do, cannot be done. If you use something like Flash, Silverlight or Java, then it should be relatively easy.
As far as I know, there is no way to do what you want to do in javascript. Its a pretty big security issue - having filesystem access in a browser.
There are a few browser plugins (java/flash/gears) that may allow you to do this sort of thing. I know with gears you can get the user to select a file - and open it to read the content using JS.

Categories

Resources