More Outlook Resource Sites

Microsoft Developer Network (MSDN)

FAQs and other general resources

share code 19-Oct-2017 09:13

Looking for help with Outlook programming projects — VSTO, add-ins, VBA, custom Outlook forms, etc.? You′ve come to the right place!

NEW! >> Subscribe to this site via RSS. For more RSS options, see the complete list of feeds on our main news page.

Code level: intermediate    Code area: Basic Outlook Printer Friendly Version
Title: VBScript: Add Note
Description: 'Prompts user for input (syntax: "@category your note's text"), saves this as a note in Microsoft Outlook. 'Note this is a stand-alone file (not launched from inside Outlook), intended so you can quickly create a note without the distraction of opening/navigating Outlook.
Date: 13-Jul-2007  09:12
Code level: intermediate
Code area: Basic Outlook
Posted by: Bob Menke
This message is displayed as VB.NET
 'addnote.vbs
'Prompts user for input (syntax: "@category  your note's text"), saves this as a note in Microsoft Outlook.

'Version History:
'v1.0 22Jun2007 Release
'
' code credit: 	http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=206579&admit=-682735245+1182363537802+28353475
' 			http://support.microsoft.com/kb/162371
' inspired by:	http://lifehacker.com/software/how-you-work/getting-things-done-with-igtd-270522.php

Option Explicit

Call Main

Sub Main ()

   Dim objApplication, objNote, strInput, strCategories, strBody, pos

   ' get user input
   ' syntax like iGTD for Quicksilver: http://microformats.org/wiki/igtd-syntax
   strInput = InputBox("Please enter your note:" + Chr(13) + Chr(13) + _
				"Syntax: @category  your note's text" + Chr(13) + _
				"             @category1,category2  your note's text" + Chr(13) + _
				"             (Note: no spaces between categories)","Quick Add Note to Microsoft Outlook")
   If Len(strInput)=0 Then Wscript.Quit 0

   ' parse user input
   pos = InStr(strInput,"@")
   If pos>0 Then
      strCategories = Mid(strInput,pos+1,InStr(strInput," ")-(pos+1))
      strBody = Right(strInput,Len(strInput)-InStr(strInput," "))
   Else
      strCategories = ""
	  strBody = strInput
   End If
   
   ' start Outlook if installed
   Set objApplication = CreateObject ("Outlook.Application")

   ' create a new note item
   ' item types: http://msdn2.microsoft.com/en-us/library/bb208104.aspx
   Set objNote = objApplication.CreateItem (5)

   ' fill in the details
   With objNote
          ' all possible fields: http://msdn2.microsoft.com/en-us/library/bb219956.aspx
		  .Categories = strCategories ' comma seperated
          .Body = strBody
          .Save
    End With
	
   ' display the new item to the user
   'objNote.Display

   ' destroy objects
   Set objNote = Nothing
   Set objApplication = Nothing
 
End Sub
All 0comments