First off you need to get to the Macros button in Outlook. To do this you need to enable the Developer Ribbon.
1) Go to File and then click on Options:
2) Then go to Customize Ribbon:
3) In the Customize Ribbon window tick the tickbox next to Developer and click okay:
4) Now that the developer tab is there you now need to create the Macro, whilst in Outlook click Alt+F11. This will bring up the Visual Basic editor.
In the Editor on the Left under Project keep expanding until you get to ‘ThisOutlookSession’ :
5) Double click on the ‘ThisOutlookSession’. In the window to your right copy the code below replacing the InsertFolderNameHere with the folder name that contains the drafts folder. In my case the folder is called my email address.
Public Sub SendDrafts() Dim lDraftItem As Long Dim myOutlook As Outlook.Application Dim myNameSpace As Outlook.NameSpace Dim myFolders As Outlook.Folders Dim myDraftsFolder As Outlook.MAPIFolder 'Send all items in the "Drafts" folder that have a "To" address filled in. 'Setup Outlook Set myOutlook = Outlook.Application Set myNameSpace = myOutlook.GetNamespace("MAPI") Set myFolders = myNameSpace.Folders 'Set Draft Folder. This will need modification based on where it's being run. Set myDraftsFolder = myFolders("InsertFolderNameHere ").Folders("Drafts") 'Loop through all Draft Items For lDraftItem = myDraftsFolder.Items.Count To 1 Step -1 'Check for "To" address and only send if "To" is filled in. If Len(Trim(myDraftsFolder.Items.Item(lDraftItem).To)) > 0 Then 'Send Item myDraftsFolder.Items.Item(lDraftItem).Send End If Next lDraftItem 'Clean-up Set myDraftsFolder = Nothing Set myNameSpace = Nothing Set myOutlook = Nothing End Sub
6) Once that has all been entered just click save. You should now have a new macro appear in the drop down list for Macros:
7) This macro is now created but now only available through that drop down list. To add it to one of your normal views you need to do the below.
Repeat instruction No. 1 & 2, then on the customize ribbon screen choose where you would like it to reside. I chose the Home (Mail) ribbon as this is the standard screen you see and the one I mostly use.
A) Click the New group button, when the New group called ‘New Group (Custom)’ appears click the rename button at the bottom and call it something else (I Just called it Macro to keep it simple)
B) On the list on your left at the top choose in the drop down list ‘Macros’ so that it will display the Macro you have just created.
C) Click the new group you created (Macro) on the right then on the left select the macro you created and click the add button, you should see the macro appear under your created group.
D) Click ok.
8) If you go back to your Outlook and home screen you should now see the macro across your top ribbon.
Macro Security Settings
You may encounter an issue where Macro’s do not run.
Go to File> Options>Trust Center>Trust Center Settings>Macro Settings
Choose one of the options, I changed mine to the below so that it notifies me over everything trying to be run.
|Related Product||Spindle Professional|
|Original Author||Liam Henshaw|
|Update Author||Vince Hodgson|