OWA Signature Update with Exchange Web Services - exchangewebservices

We're using Exchange Web Services to set user signature in Outlook Web Access. It works great, we see the signature under Options>Settings and the "Automatically include my signature on messages I send" check box is checked. We also set this programmatically.
However, when the user creates a new e-mail message in OWA the signature does not show up. A work around for this is to go to Options>Setting, uncheck the "Automatically include my signature on messages I send" check box , Save, check the check box again and save.
The code we use to set the signature looks something like this:
Folder rootFolder;
UserConfiguration OWAConfig;
rootFolder = Folder.Bind(service, WellKnownFolderName.Root);
OWAConfig = UserConfiguration.Bind(service, "OWA.UserOptions",rootFolder.ParentFolderId, UserConfigurationProperties.All);
OWAConfig.Dictionary["signaturehtml"] = "Hello World";
OWAConfig.Dictionary["autoaddsignature"] = "True";
OWAConfig.Update();
Any idea how to get around this problem?

I have some old code that does the same thing which is working fine. I have pasted the code below. There are a few minor differences between my code and yours. I am not sure if they make a difference but you may want to try it out. Here is an extract of my code with the differences highlighted with a comment:
private void SetSettingValue(UserConfiguration owaConfig, string propName, object propValue)
{
if (owaConfig.Dictionary.ContainsKey(propName))
{
owaConfig.Dictionary[propName] = propValue;
}
else
{
// Adds a key if it does not explicitly exist.
// I am not sure if it makes a difference.
owaConfig.Dictionary.Add(propName, propValue);
}
}
public void AddSignature()
{
// Extract
UserConfiguration OWAConfig = UserConfiguration.Bind(
service,
"OWA.UserOptions",
WellKnownFolderName.Root, // Binding to Root and not Root.ParentFolderId.
UserConfigurationProperties.Dictionary // Binds to Dictionary and not to All.
);
SetSettingValue(OWAConfig, "autoaddsignature", true);
SetSettingValue(OWAConfig, "signaturehtml", html);
OWAConfig.Update();
}

Related

Only one type of action can execute?

I going to show my problem with an example:
I have a button. When clicked, it creates a mail draft based on the TextInputFields in the add-on.
I have a validate function, which can say if the fields filled right or not.
If I want to notify the user somehow about the wrong fields, I have to create a notify or rebuild the card with error information. These actions can be returned in a normal Action, but not with a composeAction (because composeAction has to return with builded draft), so I have to register a composeAction and a simple action to the button.
When I clicked this kind of button, only one of the action execute and the other do nothing.
Some code about how I tried to implement:
section.addWidget(CardService.newTextButton()
.setText('Validate and Create')
.setComposeAction(CardService.newAction().setFunction('doIt'), CardService.ComposedEmailType.STANDALONE_DRAFT)
.setOnClickAction(CardService.newAction().setFunction('notify')));
ActionFunctions:
function doIt(event){
validate the event['formInput'] object;
if(valid the formInput)
create andr return the draft;
else
return null;
}
function notify(event){
validate the event['formInput'] object;
if(valid the formInput)
return null;
else
return notify or rebuilded card with error info;
}
Mostly the simple action run, and the compose do nothing. If I place Logger.log() functions in the callback function, only one appears on api log.
Anyone have tried before validate and create draft at the same click?
How about this:
var action=CardService.newAction().setFunctionName('myFunction');
var validateCreateButton=CardService.newTextButton()
.setText('Validate & Create')
.setOnClickAction(action);
section.addWidget(validateCreateButton);
function myFunction(e) {
doit(e);
notify(e);
}

onClick communication between content and background scripts not working

I am making an application that highlights key words in the current page after the user clicks my icon. I am trying to communicate between my content scripts and background script. However,my code is not working. Does anyone know how it should be written?
Here is my content script:
chrome.extension.onRequest.addListener(function(active,sender,sendResponse){
if(active.length>0){
jQuery(document).ready(function($) {
//rest of word highlighting code
}
})
here is my background.js :
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.extension.sendRequest(active);
});
Do not use the deprecated chrome.extension.sendRequest and matching events. They are old, broken and not supported, which is quite clearly said in the documentation - which shows that you did not go and read it.
The correct ones to use are chrome.runtime.sendMessage and .onMessage, but otherwise the signature is the same.
Well.. Why did you expect that to work? (unless you're not really showing us all relevant code, which is.. not helpful)
chrome.browserAction.onClicked.addListener(function(tab) {
// There is no "active" in the code anywhere to this point.
// It is treated like a variable name, one that was not yet used,
// so its contents are "undefined", and that's what you're sending.
chrome.runtime.sendMessage(active);
// Equivalent code: chrome.runtime.sendMessage(undefined);
});
And on the receiving side:
chrome.runtime.onMessage.addListener(function(active,sender,sendResponse){
// So, here "active" is undefined. It does not have a length
// parameter, and as such causes a fatal exception
// "Cannot read property 'length' of undefined"
// that you might have seen in the console of the page
if(active.length>0){
/* something */
}
})
Whatever you send is usually, but not always, an object (well, it must be JSON-serializable). If you just want to trigger something and not pass any data, there are 2 often-used conventions, either is fine:
Pass command as a value.
// Sender
chrome.runtime.sendMessage({action: "active"});
// Receiver
chrome.runtime.onMessage.addListener(function(message,sender,sendResponse){
if(message.command == "active"){
/* something */
}
// or, useful if you have many different commands:
switch(message.command){
case "active":
/* something */
break;
}
});
Set a boolean in the message:
// Sender
chrome.runtime.sendMessage({active: true});
// Receiver
chrome.runtime.onMessage.addListener(function(message,sender,sendResponse){
if(message.active){
/* something */
}
});

hash key "#" stripped from ussd code in "tel:" links on html pages

Good day all.
I have a simple link on a webpage, in where the user can call an USSD number:
*CLICK HERE AND CALL *111*2#
this is pretty straight forward; now, if I test it on desktop browser, it popups an alert asking me if I want to call (with skype) the number *111*2#, and thats ok.
with my Android phone (S Note 3), when testing this page, the phone (or something) stripped out the last "#" (only the last) from the link, resulting in a call to *111*2.
does anyone has experienced this? or knows how to prevent this?
Use URL encoding for special character in a URL. For example # equals %23
This worked for me:
<a ng-href="tel:%23 224">#224</a>
As you can see:
You need to use Uri.encode("#")
For example String number = "tel:*111*2" + Uri.encode("#");
Try this way,hope this will help you to solve your problem.
webview = (WebView) findViewById(R.id.webview);
webview.loadData("*CLICK HERE AND CALL *111*2#","text/html", "utf-16");
webview.setWebViewClient(new CustomWebViewClient());
private class CustomWebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView wv, String url) {
if(url.startsWith("tel:")) {
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse(url.replace("#","%23")));
startActivity(intent);
return true;
}
return false;
}
}
You can use below way to display the USSD in dialer
*CLICK HERE AND CALL *111*2#

LibTiff.NET append mode bug?

I've started using LibTiff.NET for writing tiff IPTC tags lately and discovered strange behavior on some files that i have here. I'm using sample code that ships with LibTiff.NET binaries, and it works fine with most of the images, but some files are having image data corruption after these lines:
class Program
{
private const TiffTag TIFFTAG_GDAL_METADATA = (TiffTag)42112;
private static Tiff.TiffExtendProc m_parentExtender;
public static void TagExtender(Tiff tif)
{
TiffFieldInfo[] tiffFieldInfo =
{
new TiffFieldInfo(TIFFTAG_GDAL_METADATA, -1, -1, TiffType.ASCII,
FieldBit.Custom, true, false, "GDALMetadata"),
};
tif.MergeFieldInfo(tiffFieldInfo, tiffFieldInfo.Length);
if (m_parentExtender != null)
m_parentExtender(tif);
}
public static void Main(string[] args)
{
// Register the extender callback
// It's a good idea to keep track of the previous tag extender (if any) so that we can call it
// from our extender allowing a chain of customizations to take effect.
m_parentExtender = Tiff.SetTagExtender(TagExtender);
string destFile = #"d:\00000641(tiffed).tif";
File.Copy(#"d:\00000641.tif", destFile);
//Console.WriteLine("Hello World!");
// TODO: Implement Functionality Here
using (Tiff image = Tiff.Open(destFile, "a"))
{
// we should rewind to first directory (first image) because of append mode
image.SetDirectory(0);
// set the custom tag
string value = "<GDALMetadata>\n<Item name=\"IMG_GUID\">" +
"817C0168-0688-45CD-B799-CF8C4DE9AB2B</Item>\n<Item" +
" name=\"LAYER_TYPE\" sample=\"0\">athematic</Item>\n</GDALMetadata>";
image.SetField(TIFFTAG_GDAL_METADATA, value);
// rewrites directory saving new tag
image.CheckpointDirectory();
}
// restore previous tag extender
Tiff.SetTagExtender(m_parentExtender);
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
After opening i see mostly blank white image or multiple black and white lines instead of text that have been written there (i don't need to read\write tags to produce this behavior). I noticed this happens when image already has a custom tag (console window alerts about it) or one of tags have got 'bad value' (console window in this case says 'vsetfield:%pathToTiffFile%: bad value 0 for "%TagName%" tag').
Original image: http://dl.dropbox.com/u/1476402/00000641.tif
Image after LibTiff.NET: http://dl.dropbox.com/u/1476402/00000641%28tiffed%29.tif
I would be grateful for any help provided.
You probably should not use CheckpointDirectory method for files opened in append mode. Try using RewriteDirectory method instead.
It will rewrite the directory, but instead of place it at it's old
location (as WriteDirectory() would) it will place them at the end of
the file, correcting the pointer from the preceeding directory or file
header to point to it's new location. This is particularly important
in cases where the size of the directory and pointed to data has
grown, so it won’t fit in the space available at the old location.
Note that this will result in the loss of the previously used
directory space.

call code behind functions with html controls

I have a simple function that I want to call in the code behind file name Move
and I was trying to see how this can be done and Im not using asp image button because not trying to use asp server side controls since they tend not to work well with ASP.net MVC..the way it is set up now it will look for a javascript function named Move but I want it to call a function named move in code behind of the same view
<img alt='move' id="Move" src="/Content/img/hPrevious.png" onclick="Move()"/>
protected void Move(){
}
//based on Search criteria update a new table
protected void Search(object sender EventArgs e)
{
for (int i = 0; i < data.Count; i++){
HtmlTableRow row = new HtmlTableRow();
HtmlTableCell CheckCell = new HtmlTableCell();
HtmlTableCell firstCell = new HtmlTableCell();
HtmlTableCell SecondCell = new HtmlTableCell();
CheckBox Check = new CheckBox();
Check.ID = data[i].ID;
CheckCell.Controls.Add(Check);
lbl1.Text = data[i].Date;
lbl2.Text = data[i].Name;
row.Cells.Add(CheckCell);
row.Cells.Add(firstCell);
row.Cells.Add(SecondCell);
Table.Rows.Add(row);
}
}
Scott Guthrie has a very good example on how to do this using routing rules.
This would give you the ability to have the user navigate to a URL in the format /Search/[Query]/[PageNumber] like http://site/Search/Hippopotamus/3 and it would show page 3 of the search results for hippopotamus.
Then in your view just make the next button point to "http://site/Search/Hippopotamus/4", no javascript required.
Of course if you wanted to use javascript you could do something like this:
function Move() {
var href = 'http://blah/Search/Hippopotamus/2';
var slashPos = href.lastIndexOf('/');
var page = parseInt(href.substring(slashPos + 1, href.length));
href = href.substring(0, slashPos + 1);
window.location = href + (++page);
}
But that is much more convoluted than just incrementing the page number parameter in the controller and setting the URL of the next button.
You cannot do postbacks or call anything in a view from JavaScript in an ASP.NET MVC application. Anything you want to call from JavaScript must be an action on a controller. It's hard to say more without having more details about what you're trying to do, but if you want to call some method "Move" in your web application from JavaScript, then "Move" must be an action on a controller.
Based on comments, I'm going to update this answer with a more complete description of how you might implement what I understand as the problem described in the question. However, there's quite a bit of information missing from the question so I'm speculating here. Hopefully, the general idea will get through, even if some of the details do not match TStamper's exact code.
Let's start with a Controller action:
public ActionResult ShowMyPage();
{
return View();
}
Now I know that I want to re-display this page, and do so using an argument passed from a JavaScript function in the page. Since I'll be displaying the same page again, I'll just alter the action to take an argument. String arguments are nullable, so I can continue to do the initial display of the page as I always have, without having to worry about specifying some kind of default value for the argument. Here's the new version:
public ActionResult ShowMyPage(string searchQuery);
{
ViewData["SearchQuery"] = searchQuery;
return View();
}
Now I need to call this page again in JavaScript. So I use the same URL I used to display the page initially, but I append a query string parameter with the table name:
http://example.com/MyControllerName/ShowMyPage?searchQuery=tableName
Finally, in my aspx I can call a code behind function, passing the searchQuery from the view data. Once again, I have strong reservations about using code behind in an MVC application, but this will work.
How to call a code-behind function in aspx:
<% Search(ViewData["searchQuery"]); %>
I've changed the arguments. Since you're not handling an event (with a few exceptions, such as Page_Load, there aren't any in MVC), the Search function doesn't need the signature of an event handler. But I did add the "tablename" argument so that you can pass that from the aspx.
Once more, I'll express my reservations about doing this in code behind. It strikes me that you are trying to use standard ASP.NET techniques inside of the MVC framework, when MVC works differently. I'd strongly suggest going through the MVC tutorials to see examples of more standard ways of doing this sort of thing.