Cyberiafreak

"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 @ http://support.microsoft.com/kb/228736

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
http://blogs.office.com/2014/03/03/create-apps-for-office-365/

2) Here is a Video of the possibilities :
http://www.youtube.com/watch?v=qryRH5xXyJk&feature=player_embedded

3) MSDN article we might need to be aware of -Office 365 APIs Preview
http://msdn.microsoft.com/en-us/library/office/dn605892.aspx

4) How to: Add Office 365 APIs to a Visual Studio project
http://msdn.microsoft.com/en-us/library/office/dn605899.aspx

UDF
5) What is UDF – http://blogs.msdn.com/b/frice/archive/2004/06/11/153891.aspx

6) UDF using .NET – http://blogs.msdn.com/b/eric_carter/archive/2004/12/01/writing-user-defined-functions-for-excel-in-net.aspx

7) http://msdn.microsoft.com/en-us/library/ms173189(v=vs.80).aspx

8) Automation Add-ins section – http://support.microsoft.com/kb/291392

XLL
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 – http://go.microsoft.com/fwlink/?LinkID=251082&clcid=0×409

11) http://blogs.msdn.com/b/andreww/archive/2007/12/09/building-an-excel-xll-in-c-c-with-vs-2008.aspx

12) http://msdn.microsoft.com/en-us/library/office/bb687861(v=office.15).aspx

13) http://support.microsoft.com/kb/178474

 

Excel
14) Understanding the Excel Object Model from a .NET Developer’s Perspective
http://msdn.microsoft.com/en-us/library/office/aa168292(v=office.11).aspx

15) How to automate Microsoft Excel from Microsoft Visual C#.NET
http://support.microsoft.com/kb/302084

16) How to transfer data to an Excel workbook by using Visual Basic .NET
http://support.microsoft.com/kb/306022

17) How to automate Excel from Visual Basic .NET to fill or to obtain data in a range by using arrays
http://support.microsoft.com/kb/302094

 

Office PIA
18) http://msdn.microsoft.com/en-us/library/15s06t57(v=vs.110).aspx

19) Primary Interop Assemblies Concept – http://msdn.microsoft.com/en-us/library/aax7sdch.aspx

20) http://msdn.microsoft.com/en-us/library/aa302338.aspx

21) Better eventing support in CLR 4.0 using NOPIA support
http://blogs.msdn.com/b/mshneer/archive/2008/10/28/better-eventing-support-in-clr-4-0-using-nopia-support.aspx

22) How to: Install Office Primary Interop Assemblies – http://msdn.microsoft.com/en-us/library/kh3965hw(v=VS.90).aspx

 

VSTO

23) Adding custom task pane
http://social.msdn.microsoft.com/Forums/vstudio/en-US/3316853c-4cec-4cf5-8cf7-5fe6f3cd1bfe/adding-custom-task-pane?forum=vsto

24) How to: Attach Managed Code Extensions to Documents (2007 System)
http://msdn.microsoft.com/en-us/library/bb772091(v=vs.90).aspx

25) Memory leak (When you automate a Off app from .NET, the Office application does not quit when you call the Quit method)
http://support.microsoft.com/kb/317109

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 C#.net. 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 – http://support.microsoft.com/kb/257757

 

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

How to use EWS API for reading SMIME email message

What is SMIMEhttp://technet.microsoft.com/en-us/library/aa995740(v=exchg.65).aspx 

class Program
{
static ExchangeService exService;

static void Main(string[] args)
{
try
{
exService = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
exService.UseDefaultCredentials = true;
exService.AutodiscoverUrl(“user@Contoso.com”, 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 “);
Console.ReadKey();
return;
}
//
byte[] resultObject= DecryptToFile(data);

if(resultObject==null)
{
Console.WriteLine(“No object retrieved from Decrypt. somthing wrong in this method”);

}
else
{
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..”);
Console.ReadKey();
}
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);
item.Load(ps);

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();
fileAttachment.Load(stream);
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;

try
{
EnvelopedCms envelopObj = new EnvelopedCms();
envelopObj.Decode(data);

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);
}
else
{
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(obj.Oid.FriendlyName);
}

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

return resultObject; ;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
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());
}

#endregion

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);
}
else
{
fs = System.IO.File.OpenWrite(strPath);
}

fs.Close();

// 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);
sw.Close();

}
}

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);

Console.WriteLine(base64);
}

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
Image

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 - http://referencesource-beta.microsoft.com/

For core lib’s – http://referencesource-beta.microsoft.com/#mscorlib

Read in detail at - http://blogs.msdn.com/b/dotnet/archive/2014/02/24/a-new-look-for-net-reference-source.aspx

Update: Now http://referencesource.microsoft.com/ 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.

http://visualstudiogallery.msdn.microsoft.com/a1166718-a2d9-4a48-a5fd-504ff4ad1b65

Here is an excellent online portal to try this out.. http://codesnippet.research.microsoft.com/ 

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 - http://support.microsoft.com/kb/2000021/en-us 
getpst

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)
DoEvents
If objVariant.Class = olMail Then
intDateDiff = DateDiff("d", objVariant.SentOn, Now)
If intDateDiff > 10 Then
' Set objArchiveFolder = objNamespace.Folders("maheshk@keepmovin.com"). _
' Folders("Inbox").Folders("Old")
objVariant.Move newFolder
movedItemCount = movedItemCount + 1
Set objArchiveFolder = Nothing
End If
End If
Next
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 - http://www.microsoft.com/net/nettechnologyguidance

.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)
 Debugger.Launch();
 Debugger.Break();

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- http://goo.gl/lKJcUh

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 : https://www.coursera.org/records/jNWWBnZgA7Uq4hfd
My certificate of credit at : https://www.coursera.org/signature/certificate/EERDVVM4WS

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

Some of my course content for reference:
Course Wiki: http://wiki.quantsoftware.org/index.php?title=Computational_Investing_I
Assignment Tooks: http://wiki.quantsoftware.org/index.php?title=QuantSoftware_ToolKit
Resources: http://wiki.quantsoftware.org/index.php?title=Resources
Misc URL’s.
https://lucenaresearch.com/
http://www.cc.gatech.edu/~tucker/
http://augmentedtrader.wordpress.com/author/tuckerbalch/
http://wiki.quantsoftware.org/index.php?title=QuantSoftware_ToolKit
https://code.google.com/p/cep-trader/
https://lucenaresearch.com/tutorial-help/technical-analysis-guide/
http://blog.enthought.com/general/enthought-sponsors-first-ny-qpug-meetup/
https://www.coursera.org/course/compinvesting1

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 -http://sdrv.ms/18nZQ7f  & Robocopy commands -http://ss64.com/nt/robocopy.html

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.

http://blogs.msdn.com/b/ivo_manolov/archive/2009/04/28/9574933.aspx

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’..
blog

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

How to launch:   http://msdn.microsoft.com/en-us/library/e74a18c4
More tweaking : http://stackoverflow.com/questions/255669/how-to-enable-assembly-bind-failure-logging-fusion-in-net

   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: http://blogs.msdn.com/b/jgoldb/archive/2008/02/04/finding-memory-leaks-in-wpf-based-applications.aspx

2) Internet Explorer client side memory leak detector /tool -> IE Sieve – http://home.wanadoo.nl/jsrosman/

3) WPF progress bar memory leak-

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

</ProgressBar>

http://connect.microsoft.com/VisualStudio/feedback/details/529736/wpf-progressbar-isindeterminate-true-causes-unmanaged-memory-leak

4) Tracking down managed memory leaks (how to find a GC leak) —> http://blogs.msdn.com/b/ricom/archive/2004/12/10/279612.aspx

5) What do the Task Manager memory columns mean? http://windows.microsoft.com/en-US/windows-vista/What-do-the-Task-Manager-memory-columns-mean

 

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

Follow

Get every new post delivered to your Inbox.