Macros to send all emails from Drafts folder at once in Outlook


There is sometimes a need to send all draft emails at once.
To do this:

  1. Start Outlook and choose Tools, Macro, Visual Basic Editor (or press Alt+F11) to open the VBA Editor.
  2. In the Project window, select Project1 and expand the tree until you see ThisOutlookSession.
  3. Select ThisOutlookSession and press F7 to open the Code window.
  4. Enter the following in the Code window:

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("Personal Folders").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
This code is from the microsoft.public.outlook.program_vba newsgroup.

"To add a macro to the toolbar, choose View, Toolbars, Customize from the main Outlook menu. On the Commands tab in the Customize dialog box, select Macros from the Categories list. You'll see a list of macros on the right. Copy the desired macro to the toolbar or to an Outlook menu. Right-click the newly created toolbar button or menu command to customize the name, button, and other features."

Comments

Popular posts from this blog

How to uninstall a broken software

Xerox 116-324 fault when printing .doc or .pdf containing callibri fonts

Create Outlook calendar item with Python