Minimize compose window and run function in an Outlook web add-in - outlook

I am currently working on a web add-in that processes, modify and then sends the email.
I'm attached to the ItemSend event: <Event Type="ItemSend" FunctionExecution="synchronous" FunctionName="validateBody" />. This validate the body and then sends it.
The problem I have is that processing the email might take up to 40 seconds and I don't want the user to be blocked for that amount of time.
I was wondering is there a way to minimize the compose window and still run the processing function and the close that minimized window once its done?
I know that the add-in only works on the current item so when I send the email I can still access the other pages but once the email is trying to send itself and close the compose window nothing happens.
This is the function that sends the email:
async function sendInBackGround(htmlArr, message = "") {
const subject = await getEmailSubject();
const messageDiv = "<div>" + message + "</div>";
for (const htmlArrObject of htmlArr) {
debugger;
var request = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
' <soap:Header><t:RequestServerVersion Version="Exchange2010" /></soap:Header>' +
' <soap:Body>' +
' <m:CreateItem MessageDisposition="SendOnly">' +
' <m:Items>' +
' <t:Message>' +
' <t:Subject>' + subject.value + '</t:Subject>' +
' <t:Body BodyType="HTML"><![CDATA[' + htmlArrObject.html + messageDiv + ']]></t:Body>' +
' <t:ToRecipients>' +
' <t:Mailbox><t:EmailAddress>' + htmlArrObject.recipient + '</t:EmailAddress></t:Mailbox>' +
' </t:ToRecipients>' +
' </t:Message>' +
' </m:Items>' +
' </m:CreateItem>' +
' </soap:Body>' +
'</soap:Envelope>';
Office.context.mailbox.makeEwsRequestAsync(request, (asyncResult) => {
console.log(request);
if (asyncResult.status === "failed") {
console.log("Action failed with error: " + asyncResult.error.message);
}
else {
console.log("Message sent!");
mailboxItem.close();
}
});
}
}
When I send the item and wait on the compose window for the process to be done, the asyncResult has a status and a value that are defined. But when I change windows while the process is running, for example I go on an other compose window and start writing another email, the asyncResult object has a status of succeeded but the value returned is undefined.
Can someone help?

I was wondering is there a way to minimize the compose window and still run the processing function and the close that minimized window once its done?
No, there is no way with web-based add-ins. You can post your feature request/suggestion to the Tech Community Page. Don't forget to choose the appropriate label(s). Feature requests on Tech Community are considered when the team go through the planning process.
As a side note, you can implement the required functionality with COM based add-ins nowadays. For example, you may consider developing a VSTO add-in instead, see Walkthrough: Create your first VSTO Add-in for Outlook for more information.

Related

Outlook StickyNote Color in Outlook on the web

I'm developing an Outlook add-in that needs to create Outlook Notes (StickyNote). Since the Outlook REST API and Graph API don't support this I'm using Exchange Web Services (EWS). I can successfully create a note like this:
createNote(subject, body) {
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
' xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"' +
' xmlns:xsd="https://www.w3.org/2001/XMLSchema"' +
' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' +
' xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">' +
' <soap:Body>' +
' <m:CreateItem MessageDisposition="SaveOnly">' +
' <m:SavedItemFolderId>' +
' <t:DistinguishedFolderId Id="notes" />' +
' </m:SavedItemFolderId>' +
' <m:Items>' +
' <t:Message>' +
' <t:ItemClass>IPM.StickyNote</t:ItemClass>' +
' <t:Subject>' + subject + '</t:Subject>' +
' <t:Body>' + body + '</t:Body> ' +
' <t:ExtendedProperty>' +
' <t:ExtendedFieldURI PropertySetId="0006200E-0000-0000-C000-000000000046" PropertyId="35584" PropertyType="Integer" />' +
' <t:Value>1</t:Value>' +
' </t:ExtendedProperty>' +
' </t:Message>' +
' </m:Items>' +
' </m:CreateItem>' +
' </soap:Body>' +
'</soap:Envelope>';
Office.context.mailbox.makeEwsRequestAsync(xml, function (result) {
if (result === Office.AsyncResultStatus.Succeeded)
console.log(result.value);
});
}
The extended property is to set the color of the note (0 = blue, 1 = green, 2 = pink, 3 = yellow, 4 = white). However, this only works in the Outlook desktop app. Outlook on the web shows all the notes as gray. I assume it uses another custom property to set the color. Anyone knows how the note color can be set in Outlook on the web?
I would suggest you get a MAPI editor like OutlookSpy of MFCMapi and look at the following properties
If i set the color in the JSON _Note property which is a JSON string like
{"schemaVersion":"beta","documentModifiedAt":"2021-01-13T02:18:33.411Z","document":{"type":"document","blocks":[{"type":"paragraph","id":"ej73vbcb-c65a-4a4e-944a-243f540eaa16","content":[{"text":"test1","styles":null}],"blockStyles":[{"textDirection":"ltr"}]},{"type":"paragraph","id":"55pcod81-f62a-4cc8-be0b-ea28404bd60b","content":null}]},"createdWithLocalId":"1f202a39-cc90-4812-b7ff-9beef48af549","createdWithLocalId#Is.Queryable":"True","createdByApp":"OWA","createdByApp#Is.Queryable":"True","color":4,"color#Is.Queryable":"True","documentModifiedAt#Is.Queryable":"True","#type.documentModifiedAt":"DateTime","#type.createdWithLocalId":"String","#type.createdByApp":"String","#type.color":"Int32"}
and then refresh OWA that will change the color of the note in OWA. Changing the #color property doesn't seem to do anything. Some problems though this is going to be unsupported, the colors don't sync between Outlook Desktop and OWA at the moment the integers values don't event align eg 3 is Yellow in the Outlook Desktop and Pink in OWA. It maybe worth asking another question on Q&A https://learn.microsoft.com/en-us/answers/topics/office-outlook-itpro.html (don't mentioned anything about trying to use code) and just ask why the colors don't sync between the Desktop and OWA when you use the client.

Form location/size FMX - Win32

i'm building an FMX app for Win32 (one form only) with C++ Builder. I'd like the program to remember where it's form was located on the users screen and it's size (it is resizeable) for the next time the user runs it.
Can someone point me in the right direction?
thanks,
relayman
UPDATE: Thanks Sam. I did what you said but wrote the position info to an SQLite db instead of text file. The db has a table named "pos" with 5 integer fields. 4 are the positions and 1 is named "item" and is just to facilitate my update query (I'm not sql expert by long shot). Note, the code below needs try/catch improvements and some tests to make sure form coordinates are valid.
This code is in the form OnShow event:
TFDQuery *query2;
query2 = new TFDQuery(NULL);
query2->Connection = Form1->FDConnection1;
query2->SQL->Text = "SELECT * FROM pos";
query2->Open();
Form1->Left = query2->FieldByName("left")->AsInteger;
Form1->Top = query2->FieldByName("top")->AsInteger;
Form1->Width = query2->FieldByName("width")->AsInteger;
Form1->Height = query2->FieldByName("height")->AsInteger;
query2->Close();
query2->DisposeOf();
This code is in the form OnClose event:
TFDQuery *queryUPDATE;
queryUPDATE = new TFDQuery(NULL);
queryUPDATE->Connection = Form1->FDConnection1;
queryUPDATE->SQL->Text = "UPDATE pos set left = '" + IntToStr(Form1->Left) + "', top = '" + IntToStr(Form1->Top) + "', width = '" + IntToStr(Form1->Width) + "', heigth = '" + IntToStr(Form1->Height) + "' WHERE item = '1'";
queryUPDATE->ExecSQL();
queryUPDATE->Close();
queryUPDATE->DisposeOf();
OnClose save the position, with, height, state, ... into an INI file. OnCreate restore all that info

Xamrin forms Display alert height

bool install = await DisplayAlert("Version " + jsonVersion + " available", "New version of application available. Please, update for new features. \n" + " \n " + "What's new in this release:\n \n" + releaseNotes, "Install Now", "Later");
How can i manage the height of the alert.
There is no customization for xamarin forms display alerts. If you want a customization I think you have to use a DependencyService and call OS Alert. or use nuget like this.
https://github.com/rotorgames/Rg.Plugins.Popup

JQM Toggle flip switch error calling refresh

i am new to JQM.
I am trying to set up a switch control for home automation. There are switches for every room to be controlled by phone or computer.
THe issue I am having is that I have one toggle flip switch which should switch the whole group on or off. The problem is the updating of the other toggle flip switches on the side, eg. when selecting 'off' for the whole group all switches should be changed to 'off' or vice versa for the 'on' option. if any of the other switches is selected the 'Whole Group' switch should not be changed.
I have tried all kinds of refresh options but either the page hangs completely or I get the following error
Error: cannot call methods on slider prior to initialization; attempted to call method 'refresh'.
I have tried all different answers given in the forum, but none is working on Chrome, Firefox or iPhone Safari.
$(document).ready(function () {
$(".tswitch").bind("change", function (event, ui) {
var n = $(this).val();
console.log('Start value n: ' + n);
if (n == '0') {
$('.tswitch').val('1');
$('.tswitch').slider("refresh");
<!--$('.tswitch').val('1').trigger('create').slider("refresh")-->
console.log('0 toggle: ' + $(this).val() + ' value n: ' + n);
} else {
$('.tswitch').val('0');
$('.tswitch').slider("refresh");
<!--$('.tswitch').val('1').trigger('create').slider("refresh")-->
<!--var fts = $('.tswitch');-->
<!--fts.val('0');-->
<!--fts.trigger('create');-->
<!--fts.slider('refresh');-->
console.log('1 toggle: ' + $(this).val() + ' value n: ' + n);
}
});
});
the code is on http://jsfiddle.net/PdkQ5/98/
also tried JQM 1.8 and 2.0

How to Get a Popup Window With Menu?

I am opening a popup window from CRM 2011 for Outlook. The problem is I need the user to be able to print. If you do it from IE the browser print menu is available but from Outlook it is not. You just get a plain window. Hitting the Alt key does nothing when a popup opens from Outlook. None of the openStdWin() options seem to actually work from Outlook.
FYI I'm trying to print Dashboards (why MS left that out is beyond me). The solution we came up with is the following code hooked to a ribbon button. Then the user uses the built-in browser print functionality and the dashboard can be printed. But not from Outlook it seems. Any suggestions? (before anybody suggests it our client thinks print-screen is unacceptable)
function printCurrentDashboard() {
if (Xrm.Page.context.isOutlookClient()) {
var pTarget = document.getElementById('dashboardFrame').src;
openStdWin(window.location.protocol + '//' + window.location.host + pTarget, 'test', 800, 600, 'menubar=yes,toolbar=yes,channelmode=no,directories=yes,fullscreen=no,location=yes,status=yes,titlebar=yes');
}
else {
var pTarget = parent.document.getElementById('dashboardFrame').src;
window.open(window.location.protocol + '//' + window.location.host + pTarget);
}
}
Try using openStdWinWithFeatures vs openStdWin.

Resources