More Outlook Resource Sites

Microsoft Developer Network (MSDN)

FAQs and other general resources

share code 16-Jul-2018 06:59

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
'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:
' inspired by:

Option Explicit

Call Main

Sub Main ()

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

   ' get user input
   ' syntax like iGTD for Quicksilver:
   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," "))
      strCategories = ""
	  strBody = strInput
   End If
   ' start Outlook if installed
   Set objApplication = CreateObject ("Outlook.Application")

   ' create a new note item
   ' item types:
   Set objNote = objApplication.CreateItem (5)

   ' fill in the details
   With objNote
          ' all possible fields:
		  .Categories = strCategories ' comma seperated
          .Body = strBody
    End With
   ' display the new item to the user

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