Get the list of installed SQL Server versions/editions with VBScript

This script works in 64bit as well as 32bit installations. This may not be a straightforward method but this works for my purpose so thought to share with public.

 

Read curretly selected mail item from Ribbon – VSTO Outlook AddIn

You need to access ActiveExplorer() so you will require reference to Microsoft.Office.Interop.Outlook.

There are few methods available if you Google but I found this handy but I make sure you care about exception handling.

Version tested: I have tried this for Office 2013.

 

Programmatically change Lync availability status

Below code snippet changes the status to Do Not Distrub mode forcefully. I have tested this with Lync 2013.

Make sure you have Lync SDK installed and have referenced Microsoft.Lync.Model

 

ETW in action – a simple-sample

using System.Diagnostics;

... 

EventInstance ei = new EventInstance(100, 1, EventLogEntryType.Information);
string[] vals = { "Test Event - a very basic event logger" };
EventLog.WriteEvent("MyEventLogger", ei, vals);

There you go… check Event Viewer -> Windows LogsApplication

 

A playlist for HTML5 Video tag

Here is a code snippet which allows you to play a list of media files.

 

Add attachments or inline images in Exchange Server mail (.NET)

Use: email.Attachments.AddFileAttachment

Example:


Ref: MSDN

 

Check if a user exists in Windows Domain – .NET

Well, this code snippet checks a the existence of a list of users and returns false if at least one is invalid.

Input format: mydomainuser;hellodomainmyname;myname;HELLOWorld

 

Send mail using Exchange Server / EWS 2.0 API

using Microsoft.Exchange.WebServices.Data;

            ExchangeService service = new ExchangeService();
            service.Credentials = new WebCredentials(“email@yourexchange.com”, “your pass”);
            service.AutodiscoverUrl(“email@yourexchange.com”, delegate(string url) { return (new Uri(url).Scheme == “https”); });
            EmailMessage email = new EmailMessage(service);
            email.ToRecipients.Add(“email@anothermail.com”);
            email.Subject = “test”;
            email.Body = new MessageBody(“test”);
            email.Send();

This should work in most cases, unless you have a more advanced configuration.

Download EWS 2.0 API  from – http://www.microsoft.com/en-in/download/details.aspx?id=35371
Reference URL: http://msdn.microsoft.com/en-us/library/office/jj220499(v=exchg.80).aspx

 

Redirect to links on random – client side

Below code will force anchor tag to direct to two different URLs on random.

<script>
$(function () {
$(“#url”).attr(“href”, (((Math.floor(Math.random() * 9) % 2) == 0) ? “http://blah.org/” : http://blee.org/));
});</script>

<a href=”http://blah.org/results” id=”url” target=”_blank”>Click Here</a>

 

C# – Count number of lines of files in a folder

Find the code snippet: