Archive for December, 2007
Automate the creation of an Outlook message with JScript
Written by Patrick on December 26, 2007 – 1:59 pm -Every so often I need a way to automatically create an Outlook email message. I could create a C# application to do this but that is usually overkill and takes too much time to maintain the source and executable. Instead I create a simple JScript file that creates the Outlook message and populates it with the necessary information.
To do this create a new file named CreateMessage.js. Paste the code below into the file. Save the file and then at the command line run this command: “cscript CreateMessage.js”. Confirm the Outlook dialog that you want to do this and the new message will appear.
var outlookApp = new ActiveXObject("Outlook.Application");
var outlookNamespace =
outlookApp.GetNameSpace("MAPI").CurrentUser;
var mailItem = outlookApp.CreateItem(0);
var olTo = 1;
var olCC = 2;
var recipient = mailItem.Recipients.Add ("User1");
recipient.Type = olTo;
var recipient = mailItem.Recipients.Add ("User2");
recipient.Type = olCC;
mailItem.Subject = "Test Subject";
mailItem.HTMLBody = "Test Body";
mailItem.Display();
outlookNamespace.Logoff;
Tags: JScript, Outlook
Posted in Scripts | No Comments »
Using unescaped paths in the Visual Studio Watch window
Written by Patrick on December 24, 2007 – 11:15 pm -I am often debugging an app in Visual Studio and add a variable containing a file path to the watch window. I’ll usually want to open the file to verify the contents so I will copy and paste the path into a command window. This is really annoying because the pasted path doesn’t work due to the double backslashes. I have to spend time converting all the double backslashes into single backslashes in order for the path to work.
Here is a simple solution to this problem: In the watch window append “,nq” to the end of the variable in the watch window. This will automatically remove the double backslashes and quotations. Once that is done you can copy/paste the string into a command window and use it without modification.
Tags: Visual Studio, VS2005Tip, VS2008Tip
Posted in Visual Studio | No Comments »
