Sample script

  • Thread starter Thread starter T. Glauner
  • Start date Start date
T

T. Glauner

I need a VBA script that does the following:

1. Take the selected (highlighted but does not have to be open) email
that can be in any folder in Outlook.
2. Move this email into a certain folder. The folder name is hardcoded
in the script.

The purpose is to have a shortcut that moves an email into a folder so
that I do not have to use the mouse and do not have to do sereral
keyboard command.

I would appreciate any sample scripts that I could use.
Thanks very much.
Tim
 
1. The object you're looking for is ActiveExplorer.Selection(1)

2. See http://www.slipstick.com/dev/code/getfolder.htm for a function to return a MAPIFolder object based on a path. You can then use:

Set objOL = CreateObject("Outlook.Application")
Set objItem = objOL.ActiveExplorer.Selection(1)
Set objFolder = GetFolder(<some path>)
If Not objItem IS Nothing And If Not objFolder Is Nothing Then
set objMovedItem = objItem.Move(objFolder)
End If
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
http://www.slipstick.com/books/jumpstart.htm
 
Back
Top