Outlook appointment using ActiveX - javascript

I would like to set up outlook appointment using ActiveX.
Following code is working. Other than the part where I have setup the timezone. which i cant seem to find how to set. Is there any API reference available to setup timezone ?
var sub = "Test";
var stDate = "01-01-2020";
var endDate = "01-01-2020";
var sBody1 = ".....";
var sBody2 = "hello ";
var sBody3 = ".....world";
if (confirm("Are you sure that you want to send an outlook invite for the meeting? Click OK to send invite.")) {
try {
outlookApp = new ActiveXObject("outlook.application");
}
catch (Error) {
alert("Please verify if your browser is enabled to run ActiveX scripts and try again!");
return false;
}
try {
nameSpace = outlookApp.getNameSpace("MAPI");
mailFolder = nameSpace.getDefaultFolder(6);
mailItem = mailFolder.Items.Add("IPM.Appointment.ConfRmReq");
mailItem.MeetingStatus = 1;
mailItem.Subject = sub;
mailItem.Start = stDate;
mailItem.End = endDate;
mailItem.TimeZones = ["Eastern Standard Time"];
//var tzEastern = tzs["Eastern Standard Time"];
mailItem.StartTimeZone = tzEastern;
mailItem.EndTimeZone = tzEastern;
var sBody = sBody1;
mailItem.Body = sBody;
sEmailList.push('Email Address');
mailItem.RequiredAttendees = sEmailList.join(';');
mailItem.Display();

You will need to retrieve the timezone from the Application.Iimezones collection. I never had luck retrieving the tz by its name, so you'd need to enumerate the time zones and check their ID / Name / StandardDesignation / DaylightDesignation properties.

Related

How to add CC using java script in ASP.net

function SendMail(to,body,sub)
{
var theApp ;
var theMailItem ;
var subject = sub;
var msg = body;
var theApp = new ActiveXObject("Outlook.Application")
var theMailItem = theApp.CreateItem(0);
theMailItem.to = to;
theMailItem.Subject = (subject);
theMailItem.Body = (msg);
theMailItem.send();
}
I'm using above code to send mails from the client machine, but in this i would like to add cc could anyone kindly help me on this or if there is any other methods to send mails from client side help is appreciated. Thanks in advance
The mail item has a CC property. Just set it before send.
theMailItem.CC = "carbon copy recipient goes here";
Also, have in mind that the property names are case sensitive. So change to to To and send to Send
var theApp = new ActiveXObject("Outlook.Application");
var objNS = theApp.GetNameSpace('MAPI');
var theMailItem = theApp.CreateItem(0);
theMailItem.cc = cc;
theMailItem.to = to;
theMailItem.Subject = (subject);
theMailItem.Body = (msg);
theMailItem.send();
I have added this line, var objNS = theApp.GetNameSpace('MAPI'); You should now be able to find the cc attribute.

Check if user exists in Active Directory from client side JavaScript

I am creating a ASP.NET page for creating AD user objects. I am using JQuery for client side validation (to check if user name already exists).
I found some script on Google which returns user properties if user is found in active directory (I will convert this to return bool).
However, if you run this script (below) outside of Visual Studio by directly double clicking ScriptFile.js it works perfectly but when you try the same through visual studio it gives object undefined error at var objRootDSE = GetObject('LDAP://RootDSE');
Here is the JavaScript function code:
function Search(search) {
var arrSearchResult = [];
var objRootDSE = GetObject('LDAP://RootDSE');
var strDomain = objRootDSE.Get("DefaultNamingContext");
strAttrib = "samaccountname";
objConnection = new ActiveXObject("ADODB.Connection");
objConnection.Provider = "ADsDSOObject";
objConnection.Open("ADs Provider");
objCommand = new ActiveXObject("ADODB.Command");
objCommand.ActiveConnection = objConnection;
var Dom = "LDAP://" + strDomain;
var arrAttrib = strAttrib.split(",");
objCommand.CommandText = "Select '" + strAttrib + "' From '" + Dom + "' WHERE objectCategory = 'user' AND objectClass='user' AND samaccountname='" + search + "' ORDER BY samaccountname ASC";
try {
objRecordSet = objCommand.Execute();
objRecordSet.Movefirst;
while (!(objRecordSet.EoF)) {
var locarray = new Array();
for (var y = 0; y < arrAttrib.length; y++) {
locarray.push(objRecordSet.Fields(y).value);
}
arrSearchResult.push(locarray); objRecordSet.MoveNext;
}
return arrSearchResult;
}
catch (e)
{ alert(e.message); }
}
Please suggest how to make this work in visual studio or some other way to check if user exists in AD from client side.

Is there a way of Creating lnk file using javascript

I would like to give the users in my website the ability to download a "lnk" file.
My idea is to generate this file with to contain an address that can be used only once.
Is there a way to generate this file in javascript?
The flow is something like -
the user presses a button
the javascript generates this file and downloads it to the user's machine
the user sends this file to another user to use this one-time-address from his machine
Is something like this is doable in javascript from the client side? or would i need to generate this file using java server side?
This is a faithful translation of mslink.sh.
I only tested my answer in Windows 8.1, but I would think that it works in older versions of Windows, too.
function create_lnk_blob(lnk_target) {
function hex_to_arr(s) {
var result = Array(s.length / 2);
for (var i = 0; i < result.length; ++i) {
result[i] = +('0x' + s.substr(2*i, 2));
}
return result;
}
function str_to_arr(s) {
var result = Array(s.length);
for (var i = 0; i < s.length; ++i) {
var c = s.charCodeAt(i);
if (c >= 128) {
throw Error("Only ASCII paths are suppored :-(");
}
result[i] = c;
}
return result;
}
function convert_CLSID_to_DATA(s) {
var idx = [[6,2], [4,2], [2,2], [0,2],
[11,2], [9,2], [16,2], [14,2],
[19,4], [24,12]];
var s = idx.map(function (ii) {
return s.substr(ii[0], ii[1]);
});
return hex_to_arr(s.join(''));
}
function gen_IDLIST(s) {
var item_size = (0x10000 + s.length + 2).toString(16).substr(1);
return hex_to_arr(item_size.replace(/(..)(..)/, '$2$1')).concat(s);
}
var HeaderSize = [0x4c, 0x00,0x00,0x00],
LinkCLSID = convert_CLSID_to_DATA("00021401-0000-0000-c000-000000000046"),
LinkFlags = [0x01,0x01,0x00,0x00], // HasLinkTargetIDList ForceNoLinkInfo
FileAttributes_Directory = [0x10,0x00,0x00,0x00],
FileAttributes_File = [0x20,0x00,0x00,0x00],
CreationTime = [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00],
AccessTime = [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00],
WriteTime = [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00],
FileSize = [0x00,0x00,0x00,0x00],
IconIndex = [0x00,0x00,0x00,0x00],
ShowCommand = [0x01,0x00,0x00,0x00], //SW_SHOWNORMAL
Hotkey = [0x00,0x00], // No Hotkey
Reserved = [0x00,0x00],
Reserved2 = [0x00,0x00,0x00,0x00],
Reserved3 = [0x00,0x00,0x00,0x00],
TerminalID = [0x00,0x00],
CLSID_Computer = convert_CLSID_to_DATA("20d04fe0-3aea-1069-a2d8-08002b30309d"),
CLSID_Network = convert_CLSID_to_DATA("208d2c60-3aea-1069-a2d7-08002b30309d"),
PREFIX_LOCAL_ROOT = [0x2f],
PREFIX_FOLDER = [0x31,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00],
PREFIX_FILE = [0x32,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00],
PREFIX_NETWORK_ROOT = [0xc3,0x01,0x81],
PREFIX_NETWORK_PRINTER = [0xc3,0x02,0xc1],
END_OF_STRING = [0x00];
if (/.*\\+$/.test(lnk_target)) {
lnk_target = lnk_target.replace(/\\+$/g, '');
var target_is_folder = true;
}
var prefix_root, item_data, target_root, target_leaf;
if (lnk_target.substr(0, 2) === '\\\\') {
prefix_root = PREFIX_NETWORK_ROOT;
item_data = [0x1f, 0x58].concat(CLSID_Network);
target_root = lnk_target.subtr(lnk_target.lastIndexOf('\\'));
if (/\\\\.*\\.*/.test(lnk_target)) {
target_leaf = lnk_target.substr(lnk_target.lastIndexOf('\\') + 1);
}
if (target_root === '\\') {
target_root = lnk_target;
}
} else {
prefix_root = PREFIX_LOCAL_ROOT;
item_data = [0x1f, 0x50].concat(CLSID_Computer);
target_root = lnk_target.replace(/\\.*$/, '\\');
if (/.*\\.*/.test(lnk_target)) {
target_leaf = lnk_target.replace(/^.*?\\/, '');
}
}
var prefix_of_target, file_attributes;
if (!target_is_folder) {
prefix_of_target = PREFIX_FILE;
file_attributes = FileAttributes_File;
} else {
prefix_of_target = PREFIX_FOLDER;
file_attributes = FileAttributes_Directory;
}
target_root = str_to_arr(target_root);
for (var i = 1; i <= 21; ++i) {
target_root.push(0);
}
var id_list_items = gen_IDLIST(item_data);
id_list_items = id_list_items.concat(
gen_IDLIST(prefix_root.concat(target_root, END_OF_STRING)));
if (target_leaf) {
target_leaf = str_to_arr(target_leaf);
id_list_items = id_list_items.concat(
gen_IDLIST(prefix_of_target.concat(target_leaf, END_OF_STRING)));
}
var id_list = gen_IDLIST(id_list_items);
var data = [].concat(HeaderSize,
LinkCLSID,
LinkFlags,
file_attributes,
CreationTime,
AccessTime,
WriteTime,
FileSize,
IconIndex,
ShowCommand,
Hotkey,
Reserved,
Reserved2,
Reserved3,
id_list,
TerminalID);
return new Blob([new Uint8Array(data)], { type: 'application/x-ms-shortcut' });
}
var blob = create_lnk_blob('C:\\Windows\\System32\\Calc.exe');
Use it like:
var blob_to_file = create_lnk_blob('C:\\Windows\\System32\\Calc.exe');
var blob_to_folder = create_lnk_blob('C:\\Users\\Myself\\Desktop\\'); // with a trailing slash
Demo: http://jsfiddle.net/5cjgLyan/2/
This would be simple if your website allows php.
If your script is part of an html file, just write the the javascript as if you were writing it to send a static lnk file. Then, at the lnk address part, break apart the javascript into two parts, breaking into html. Then at that point, put in
<?php /*PHP code set a variable *? /* PHP code to generate proper string*/ PRINT /*PHP variable*/
?>
I think make it pure client is impossible.
Even the web rtc protocol need at least one iceServer to signal other client.
And I think the easiest way to do that is use http://peerjs.com/
you could first create a clinet token of the room owner
//room owner side
peer.on('open', function(my_peer_id) {
console.log('My peer ID is: ' + my_peer_id);
});
And send the token to any other you want (by text file, web chat ...etc)
Then other connect it use the token above
//the other one
var conn = peer.connect(other_peer_id);
After the room owner detected someone entered the room.
Disconnect from signal server, so the token will become unusable
//room owner side
peer.disconnect()
About generate and read file by client side, I recommend you read article below.
http://www.html5rocks.com/en/tutorials/file/dndfiles/ read from file
How to use filesaver.js save as file
I believe the compatibility of fileReader api and blob doesn't matter.
Since there will never be a browser which support webrtc but not support fileReader api

How to pass parameters to local Prettydiff.com

I've downloaded a copy of PrettyDiff to embed in my own local application, so I can compare two AJAX loaded files that are in two variables.
Unfortunately, I can't seem to make prettydiff work. Here's how I try :
var example1 = getFile('exemple1.txt');
var example2 = getFile('exemple2.txt');
var output = prettydiff("/*prettydiff.com api.lang: 8, api.mode: diff, api.diffview: inline, api.source:example1, api.diff: example2 */");
document.getElementById("output").innerHTML = output[0];
All I get is "Error: Source sample is missing.".
I've also tried to make an "api" variable that I fill with the parameters, but that doesn't work either.
The documentation doesn't give any example on how to pass the parameters (options, source and diff texts).
Anyone knows ?
Ok, I found out a way to get it working. I still don't know the fuss about the parameters as comments as specified in the docs, but you can create a js object and pass all your parameters :
var api = new Object();
api.mode = "diff";
api.diffview = "inline";
api.lang = 8;
api.source = example1;
api.diff = example2;
var output = prettydiff(api);
You can use prettydiff option like this.
const prettydiff = require("prettydiff");
let options = prettydiff.options;
options.source = content_Old;
options.diff = content_New;
options.diff_format = "html";
options.lang = "script";
options.color = "white";
options.diff_space_ignore = false;
options.diff_view = "sidebyside";
options.lexer = "script";
options.sourcelabel = "Original File";
options.difflabel = "Updated File";
options.mode = "diff";
options.parse_format = "htmltable";
options.list_options = true;
options.crlf = false;
options.force_indent = true;
outputHtml = prettydiff();

Use JScript to insert Price List on Quote onOpen in Microsoft Dynamics CRM 2011

Here is my code, I get an object error onLoad. Please help.
function Setlook()
{
var lookup = new Object();
var lookupValue = new Array();
lookup.id = "7b31D4D998-F124-E111-96C3-1CC1DEEA";
lookup.entityType = 1022;
lookup.name = "Default";
lookupValue[0] = lookup;
Xrm.Page.getAttribute(“pricelevelid”).setValue(lookupValue);
}
The code itself looks correct, but the GUID of the lookup doesn't. It doesn't have the right format nor does it have the right number of characters (32). Fixing that should eliminate the error.
Here is the proper syntax, the important thing is to have the correct .typename
function Setlook()
{
var value = new Array();
value[0] = new Object();
value[0].id = '{31D4D998-F124-E111-96C3-1CC1DEE8EC2D}';
value[0].name = 'Default';
value[0].typename = 'pricelevel';
Xrm.Page.getAttribute("pricelevelid").setValue(value);
}

Categories

Resources