"Fortunate are those who take the first steps.” ― Paulo Coelho

Profman2.exe – MAPI Profile Manager v2.0

Profman2.exe is a self-extracting achieve that contains a sample program demonstrating how to use the MAPI interfaces and methods that pertain to the manipulation and creation of MAPI profiles.

Here is a list of its functionality:

  • Create a new blank profile.
  • Add services to a profile.
  • Delete services from a profile.
  • List the services in a profile.
  • Add providers to a service.
  • Delete providers from a service.
  • List the providers in a service.
  • List the available properties of a service (even ones that are normally inaccessible).
  • List the available properties of a provider (even ones that are normally inaccessible).
  • Outlook 2000 Compliant (reads proper location of MAPISVC.inf file)

download @

April 18, 2014 Posted by | Uncategorized | | Leave a comment

From training-links for later reading { O365 apps, Office PIA, XL, VSTO }

O365 web apps development
1) The Office 365 platform —new opportunities for developers

2) Here is a Video of the possibilities :

3) MSDN article we might need to be aware of -Office 365 APIs Preview

4) How to: Add Office 365 APIs to a Visual Studio project

5) What is UDF –

6) UDF using .NET –


8) Automation Add-ins section –

9) What is XLL – An XLL is an add-in for Microsoft Excel that you can build with any compiler that supports building DLLs (dynamic link libraries).
10) Download XLL SDK from –×409





14) Understanding the Excel Object Model from a .NET Developer’s Perspective

15) How to automate Microsoft Excel from Microsoft Visual C#.NET

16) How to transfer data to an Excel workbook by using Visual Basic .NET

17) How to automate Excel from Visual Basic .NET to fill or to obtain data in a range by using arrays


Office PIA

19) Primary Interop Assemblies Concept –


21) Better eventing support in CLR 4.0 using NOPIA support

22) How to: Install Office Primary Interop Assemblies –



23) Adding custom task pane

24) How to: Attach Managed Code Extensions to Documents (2007 System)

25) Memory leak (When you automate a Off app from .NET, the Office application does not quit when you call the Quit method)

April 18, 2014 Posted by | Uncategorized | | Leave a comment

Office server side automation is not supported- famous KB 257757

There is no surprise still developers tend to code some kind of office automation on server without knowing that is not supported by us.
Recently I have seen a case where the developer is creating an excel pivot charts in server(automation) using SQL Server, DTS along with some programming with It was working for him but all sudden it broke after migrating to latest server OS.
Here is the famous KB article which we keep sharing with dev’s and also famously referred in MS as “2 5 7 7 5 7″ which talks about why this is not supported. More at; 257757 KB here –


April 17, 2014 Posted by | Uncategorized | | Leave a comment

How to use EWS API for reading SMIME email message

What is SMIME 

class Program
static ExchangeService exService;

static void Main(string[] args)
exService = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
exService.UseDefaultCredentials = true;
exService.AutodiscoverUrl(“”, RedirectionCallback);

Console.WriteLine(“Connected(Autodiscovered EWS Endpoint)- ” + exService.Url);

//find the trace log dumped in debug\log.txt
exService.TraceEnabled = true;
exService.TraceListener = new TraceListener();
exService.TraceEnablePrettyPrinting = true;

Console.WriteLine(“Getting inbox items..”);
byte[] data = GetInboxMailItems();

if (data == null)
Console.WriteLine(“No Mails retreived “);
byte[] resultObject= DecryptToFile(data);

Console.WriteLine(“No object retrieved from Decrypt. somthing wrong in this method”);

string uniqueFname = Path.GetRandomFileName()+”.eml”;
Console.WriteLine(@”Decrypted EML file dumped here — c:\temp\” + uniqueFname);

//Find the decrypted file here
//Load this file in Outlook for testing.
File.WriteAllBytes(@”c:\temp\” + uniqueFname, resultObject);

//write the decrypted content to a file – mail item .eml
Console.WriteLine(“Press any key to exit..”);
catch (Exception ex)
Console.WriteLine(“Error while initializing..” + ex.ToString());

/// <summary>
/// </summary>
private static byte[] GetInboxMailItems()
byte[] data = null;

//Get inbox unread mails (have a mail ready for decrypt which is signed & decrypt)
Folder inbox = Folder.Bind(exService, WellKnownFolderName.Inbox);
SearchFilter sf = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));

ItemView view = new ItemView(1);

FindItemsResults<Item> findResults = exService.FindItems(WellKnownFolderName.Inbox, sf, view);

//Have atleast 1 unread ‘encrypted,signed’ mail for this testing
if (findResults.TotalCount == 0)
return data;
Console.WriteLine(“No Mails retreived”);

//Loop through the items and do whatever is required.
foreach (Item item in findResults)
//Load the mail item
PropertySet ps = new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.Attachments);

foreach (Microsoft.Exchange.WebServices.Data.Attachment attach in item.Attachments)
// find the encrypted mails attachment- in general body and any mail content for encrypted mail would be bundled as smime.p7m file in mailstore
if (attach.Name == “smime.p7m”)
Console.WriteLine(“Process smime.p7m file”);
FileAttachment fileAttachment = (FileAttachment)attach;
MemoryStream stream = new MemoryStream();
StreamReader stReader = new StreamReader(stream);
stream.Seek(0, SeekOrigin.Begin);
data = stream.GetBuffer();

return data;
return data;

/// <summary>
/// </summary>
/// <param name=”data”></param>
private static byte[] DecryptToFile(byte[] data)
byte[] resultObject = null;

EnvelopedCms envelopObj = new EnvelopedCms();

Console.WriteLine(“Encryption Algorithm: Name={0}”, envelopObj.ContentEncryptionAlgorithm.Oid.FriendlyName);
Console.WriteLine(“Key length={0}”, envelopObj.ContentEncryptionAlgorithm.KeyLength);
Console.WriteLine(“Recipients ({0})”, envelopObj.RecipientInfos.Count);

foreach (RecipientInfo r in envelopObj.RecipientInfos)
Console.WriteLine(” Encrypted key={0}”, BitConverter.ToString(r.EncryptedKey));
Console.WriteLine(” Encryption alg={0}”, r.KeyEncryptionAlgorithm.Oid.FriendlyName);

if (r.RecipientIdentifier.Type == SubjectIdentifierType.IssuerAndSerialNumber)
X509IssuerSerial xi = (X509IssuerSerial)r.RecipientIdentifier.Value;
Console.WriteLine(” Issuer={0}”, xi.IssuerName);
Console.WriteLine(” SerialNumber={0}”, xi.SerialNumber);
Console.WriteLine(” SubjectKeyInfo={0}”, r.RecipientIdentifier.Value);

Console.WriteLine(“Certificates ({0})”, envelopObj.Certificates.Count);

foreach (X509Certificate2 cert in envelopObj.Certificates)
Console.WriteLine(“Subject={0}”, cert.SubjectName);

Console.WriteLine(“Unprotected Attributes ({0})”, envelopObj.UnprotectedAttributes.Count);

foreach (CryptographicAttributeObject obj in envelopObj.UnprotectedAttributes)

Console.WriteLine(“Success. Decrypted… !!”);
resultObject = envelopObj.ContentInfo.Content;

return resultObject; ;
catch (Exception ex)
return resultObject;

/// <summary>
/// </summary>
/// <param name=”url”></param>
/// <returns></returns>
static bool RedirectionCallback(string url)
// Return true if the URL is an HTTPS URL.
return url.ToLower().StartsWith(“https://&#8221;);

/// <summary>
/// </summary>
public class TraceListener : ITraceListener
#region ITraceListener Members

public void Trace(string traceType, string traceMessage)
CreateXMLTextFile(traceType + ” — ” + traceMessage.ToString());


private void CreateXMLTextFile(string traceContent)
string strPath = System.AppDomain.CurrentDomain.BaseDirectory;
strPath = strPath + “\\Log.txt”;
System.IO.FileStream fs;
if (System.IO.File.Exists(strPath) == false)
fs = System.IO.File.Create(strPath);
fs = System.IO.File.OpenWrite(strPath);


// Create an instance of StreamWriter to write text to a file.
System.IO.StreamWriter sw = System.IO.File.AppendText(strPath);
sw.WriteLine(System.DateTime.Now.ToString() + “: ” + traceContent);


April 15, 2014 Posted by | Uncategorized | , , | Leave a comment

How to convert Hex to Base64 in C#

Base64 is a group of similar binary-to-text encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation. The term Base64 originates from a specific MIME content transfer encoding.

Base64 encoding schemes are commonly used when there is a need to encode binary data that needs to be stored and transferred over media that is designed to deal with textual data. This is to ensure that the data remains intact without modification during transport. Base64 is commonly used in a number of applications including email via MIME, and storing complex data in XML.

//Convert Hex to Base64
static void Main(string[] args)
string hexstr = “040000008200E00074C5B7101A82E0080000000622029301EB4592B71528F44A48D7″;
byte[] data = ConvertFromStringToHex(hexstr);
string base64 = Convert.ToBase64String(data);


public static byte[] ConvertFromStringToHex(string inputHex)
inputHex = inputHex.Replace(“-”, “”);

byte[] resultantArray = new byte[inputHex.Length / 2];
for (int i = 0; i < resultantArray.Length; i++)
resultantArray[i] = Convert.ToByte(inputHex.Substring(i * 2, 2), 16);
return resultantArray;

April 15, 2014 Posted by | Uncategorized | | Leave a comment

How to view assemblies in GAC as like Explorer files and folders

If you navigate to Assembly folder say C:\Windows\assembly in Explorer, you could see the assemblies without folder structure where as you will see a structured directories like GAC_32, GAC_MSIL, Nativeimages, tmp folders in Command prompt. If you want to browse the GAC like any other folder structure. you can try this simple regedit entry-
Create a DWORD value named “DisableCacheViewer” and set it to value 1 under reghives -HKLM\Software\Microsoft\Fusion
Now explore to c:\windows\assembly, you will see something like this

February 28, 2014 Posted by | Uncategorized | | 1 Comment

Browsing .NET Reference Source

Finally, .NET team announced online version of .NET assembly references. Yes, You can browse through any of the .NET class library code easily.

Link -

For core lib’s –

Read in detail at -

Update: Now is updated with easier interface.

February 25, 2014 Posted by | Uncategorized | Leave a comment

Bing Code Search for C#

The Bing Code Search add-in for Visual Studio 2013 makes it easier for .NET developers to search for and reuse code samples from across the coding community, including MSDNStackOverflowDotnetperls and CSharp411.

Bing Code Search improves developer productivity and speed by bringing the experience of searching for reusable C# code into Visual Studio IDE.

Here is an excellent online portal to try this out.. 

Note: Oops this works only with VS 2013 :(

February 18, 2014 Posted by | .NET General, Uncategorized | Leave a comment

How to get Outlook PST path quickly with an exe.

About GetPst.exe tool in action. Read here - 

February 9, 2014 Posted by | Outlook | Leave a comment

Outlook:VBA#1 [How to move older mails to archive folders using code]

Private Sub Application_Startup()

Dim objOutlook As Outlook.Application
Dim objInboxFolder As Outlook.MAPIFolder
Dim myNewFolder As Outlook.Folder
Dim objNamespace As Outlook.NameSpace
Set objOutlook = Application
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objInboxFolder = objNamespace.GetDefaultFolder(olFolderInbox)
Set newFolder = objInboxFolder.Folders.Add("Test-Archived-Jan2014")
Dim movedItemCount As Long

For intCount = objInboxFolder.Items.Count To 1 Step -1
Set objVariant = objInboxFolder.Items.Item(intCount)
If objVariant.Class = olMail Then
intDateDiff = DateDiff("d", objVariant.SentOn, Now)
If intDateDiff > 10 Then
' Set objArchiveFolder = objNamespace.Folders(""). _
' Folders("Inbox").Folders("Old")
objVariant.Move newFolder
movedItemCount = movedItemCount + 1
Set objArchiveFolder = Nothing
End If
End If
MsgBox "Done, archived:#" & movedItemCount

End Sub

January 31, 2014 Posted by | Outlook, VBA | Leave a comment

Design scenarios from – .NET Technology Guide for Business Applications.pdf

I highly recommend this pdf for anyone who is looking for design guide in .NET.

Note: It also talks about Silverlight scope, migration & suggestions. Get one from here -

.NET Technology Guide for Business Applications

January 6, 2014 Posted by | .NET General | Leave a comment

How to attach Visual studio dynamically

I never thought this would be so easy with this couple of statements. All these days, I used to put a hard coded message box thrown up and then try to attach manually VS by selecting that new process.  But this one is very useful if you want to do automatically break in VS.

if (!Debugger.IsAttached)

This would be useful if you are debugging multiple process in the Visual Studio – Ley say you HelloWorld.exe is creating a new exe LogViewer.exe and yourself want to debug end to end all in same VS.  More at MSDN-

January 3, 2014 Posted by | .NET General | 1 Comment

My First Coursera Certification- Computational Investing, Part I (Signature Track) experience

Wow, what a news to start my Monday morning – Yes, I’m thrilled to see and recieve my first ever -MOOC certification, so happy to share here in my blog ( b.t.w completed 9 years of tech blogging J.
I would like to write about my little experience with Coursera (MOOC) program by Georgia Ins- of Technology so readers can make use of it. Watch out, there is a part II also going to start which is of Machine learning I believe. I’m excited and waiting for it.
My Course review:
Honestly I was not so serious when I enrolled for this course, but once after the first week sign up and enrolled with signature track(49$) I became more punctual, serious and started learning python and doing assignment following strict timeline. Python on initial take was not easy, but you would enjoy after a week with assignments.. I bet this is going to be hair pulling if you don’t know python..

Course name:  “Computational Investing, Part I”
Prof Name: Prof Tucker Balch
Programming Lang : Python ,QuantSoftware ToolKit, libs like Numpy, Matplotlib & Pandas
Duration : 8 weeks, Time commitment: 8-12 hours/week
Fee: 49$, should have webcam and submit all assignments over the webcam presence with typing analsis program to avoid copying etc..
Certification validity : Life time think so..
My personal rating : 4.5/5,
Do I recommend: Yes, very much. I was about to sign up for other management course for whopping 7.5 Lakh ( ePGP ) but this is far better than that in short span of time to learn financial fundamentals and deep analysis in a clear way. I thank Dr. Balch for his trading related expertise.
What I learned :
1) Python programming with various supporting lib’s.
2) Domain : Developing trading strategies, event profiling, portfolio optimization, and simulation of trading strategies to analyze portfolio performance and risks etc in a very clear way and in a short period of time. Various aspects of investing like – Company valuation, the Capital Assets Pricing Model (CAPM), Efficient Markets Hypothesis, the role of information in pricing, historical data and its manipulation, portfolio performance assessment and optimization.


Online course record :
My certificate of credit at :

Mahesh Kumar R
GRADE 100.0%
November 15th 2013
Student has earned a certificate with distinction.
Instructors: Dr. Tucker Balch,
Duration of course: 8 weeks

Some of my course content for reference:
Course Wiki:
Assignment Tooks:
Misc URL’s.

Looking for the part -2 Computational Investing – Machine Learning/Algorithmic Trading by coming fall 2014 which is going to be challenging and interesting think so.. 

November 18, 2013 Posted by | Certification | Leave a comment

Robocopy download and command help

I cannot stop myself recommending ‘Robocopy’ for copying big files and folders across network. It simply does it job neatly and FASTER.

Download -  & Robocopy commands -

Handy one c:>  robocopy.exe “Z:\Comp Ver 4.11″ “D:\ThirdParty_Build” “my_big_file.*”   – this to copy zip file.

November 12, 2013 Posted by | .NET General | Leave a comment

WPF Application Quality Guide

“WPF Application Quality Guide” – our single-stop document for WPF application and component developers and testers.

November 3, 2013 Posted by | WPF | Leave a comment

How to find missing dll in .NET? Fuslogvw.exe

Let say our app is ready for deployment for the first time or recompiled. And we want to double check whether all the dependencies were copied properly with right versioned assemblies referenced. Then here is the tool which would help you to avoid running into problem like ‘Could not load file or assembly’..

Here is the tool which gives you a list of bind failures in a log.

How to launch:
More tweaking :

   Note: Make sure you run this tool with admin privilege. 

November 3, 2013 Posted by | .NET General | Leave a comment

WPF and IE Memory leak -tools & links

Worth mentioning -

1) WPF:

2) Internet Explorer client side memory leak detector /tool -> IE Sieve –

3) WPF progress bar memory leak-

<ProgressBar Name=”Progress” Width=”250″ Height=”15″ Minimum=”0″ Maximum=”1″ Margin=”10″ IsIndeterminate=”True”>


4) Tracking down managed memory leaks (how to find a GC leak) —>

5) What do the Task Manager memory columns mean?


October 24, 2013 Posted by | Memory, windbg | Leave a comment


Get every new post delivered to your Inbox.