3000AD Knowledge Base
Home » Categories » Knowledge Base Home » PDF-eXPLODE » Tips N Tricks

How can I automatically SEND all my emails in the DRAFTS folder of MS Outlook?

ISSUE:

 I inadvertently set my PDF-eXPLODE email connection configuration to go to the  DRAFTS folder of MS Outlook (MAPI connection). I have tried dragging the emails from DRAFTS to OUTBOX folder and then clicking the SEND/RECEIVE button, but nothing happened.  Now I believe I have to open each 'draft' email manually and then click SEND. I have more than 500 emails in the DRAFTS folder awaiting SEND. I need a way to send these automatically without having to open each one and click SEND thereby avoiding hours of work.  Can this be done?

   

ANSWER:

MS Outlook allows you to save many emails into the DRAFTS folder. However, there is no standard functionality that exists to be able to send those emails automatically in bulk, no ' SEND DRAFT EMAILS' button; however this can be achieved by copying and pasting the VBA program code below into a Outlook macro and assigning the macro to an Outlook ' Quick Access Toolbar  ' button. Some of the following tip comes from https://www.datanumen.com/blogs/

  1. Press  [ALT + F11]  to access the shortcut for the Visual Basic (VBA) editor interface.
  2. If you see just the VBA Project name in bold on the Left Hand pane, then right click on the project name, and select Insert  and in the fly-out menu, select Module   OR
  3. If you see a menu item ' Modules ' under the Project name, you can alternatively right click on Modules and on the drop down menu, select Insert and in the fly out menu, click on Module  (as in this image below) which will open a new code screen on the right window pane. Either of #2 or #3 is suitable for creating a blank Module in the right hand pane.

     

  4.   Now copy all the code (beginning with Sub SendAllDraftEmails() to End Sub )  from the yellow window below. You can alternatively click the attachment to this article ( VBCode_SendFromDrafts.txt ) and download it to your Browser's download folder.  Then open the downloaded attachment in Notepad; it may not show the line breaks, so you will have to adjust the code so it looks like the code in the "yellow" window below.  

  5. Now paste the copied code into the white background VB code window in Outlook. then click the SAVE button.
  6. Finally, click menu FILE/ Close and Return to Microsoft Outlook  .
Send_All_Draft_Emails

Sub SendAllDraftEmails()

  Dim objDrafts As Outlook.Items
  Dim objDraft As Object
  Dim strPrompt As String
  Dim nResponse As Integer
  Dim i As Long
  Dim merror As Integer, Gcount As Integer

  On Error GoTo err_handle

  Set objDrafts = Outlook.Application.Session.GetDefaultFolder(olFolderDrafts).Items
  Gcount = objDrafts.Count

  If objDrafts.Count > o Then
      strPrompt = "Are you sure you want to send out all the drafts?"
      nResponse = MsgBox(strPrompt, vbQuestion + vbYesNo, "Confirm Sending")

      If nResponse = vbYes Then
            For i = objDrafts.Count To 1 Step -1
                  objDrafts.Item(i).Send
             Next
      End If

      If merror > 0 And merror = Gcount Then
             MsgBox "No Draft Emails Sent!", vbCritical, "Email Sending Errors!"
      ElseIf merror > 0 And merror < Gcount Then
             MsgBox "Some Draft Emails were sent - " & Trim(Str(merror)) & " emails were not sent", vbCritical, "Email Sending Errors!"
      Else
             MsgBox "All Draft Emails Sent!", vbInformation, "Email Sending"
      End If
  Else
      MsgBox "No Draft Emails Found!", vbExclamation, "No Draft Emails Found"
  End If

  Exit Sub

err_handle:

  If Err = "-2147467259" Then
      MsgBox "There must be at least one email address or contact group in the TO, CC or BCC fields" & vbCrLf & "Fix it and re-run your emails", vbExclamation, "Error in Email Address!"
      merror = 1 + merror
      Resume Next
  End If

End Sub

 

The above screen shows you how your program code (white) window will look after you pasted a copy of the code from the yellow window. (The above is a MS Outlook 2010 window)

Highlight the project name at the top (in bold) in the left-hand pane and then change the name of the project in the Properties  window below in the left hand pane - see image below

 

 

We now have to assign a button to this macro on to the Quick Access Toolbar in Outlook

  • Go to menu  File  --> Options --> Quick Access Toolbar  tab.
  • Now follow the steps shown in the picture below to add the new macro to Quick Access Toolbar.
    1. In the drop down 'Choose command from:',  select Macros
    2. In the box below, select the 'SendAllDraftEmails' and click Add..
    3. SendAllDraftEmails  code item will move to the righthand window and will be assigned a default icon on the Toolbar.
    4.   
    5. To change the default icon assigned to the macro, click on the MODIFY button once you select/highlight the Macro name.
    6. Click OK button to exit the Quick Access Toolbar configuration screen. Once you exit, you will see the Quick Access Toolbar with a new button, as indicated by the red arrow in this image below.

  • Note -   If you have more than one email account in Outlook, then the 'DRAFTS' folder is taken to be the DRAFTS folder for the  default email address. You can change your default to process emails in a different DRAFTS email folder (select FILE menu/Info/Account Settings  and when the email account listing window opens, highlight the email account and click Set as Default

 

  • Now click the Macro button in the Quick Access Toolbar  to commence processing/sending emails.

  

 

Tip:  

If you want to exclude some of the emails in the Drafts folder from sending at this time, make a subfolder in Drafts like "On Hold". Then drag the emails you don't want to send into this subfolder. They will not get sent and when you are ready, just drag them back into the Drafts folder, then click your macro 'SendAllDraftEmails' run button.

 

Note:

As stated earlier in this KB article, if you have more than one email account set up in MS Outlook (see FILE/INFO/ACCOUNT SETTINGS) , then the 'SendAllDraftEmails' button will only send the emails from the Drafts folder of the account set as default.

 

 

If you have a paid PDF-eXPLODE Annual Support Plan, you can email us at support@3000ad.com.au for help with any issue(s) you are having in getting this working. 

 

 

 

Comments Comments (7)
Comment by Mark Fonseca on Tue, Jul 24th, 2018 at 2:48 AM
If you send an email with embedded images to the DRAFTS folder instead of direct sending, MS Outlook removes the embedded images and places them as attachments. This will then require you to manually fix this (by re-embedding the image) and sending them one by one. The code supplied above will not resolve this problem.
Comment by Mihai-Gabriel Albert on Fri, Jul 20th, 2018 at 7:55 PM
if I have pictures in the email that are stored on my pc and referenced in email body, when I run the macro the pictures are not sent.
Comment by Mark Fonseca on Thu, Apr 5th, 2018 at 7:44 PM
In response to Paul‘s comment, the error he is getting is "This method can‘t be used with an inline response mail item." This error is specific to Outlook 2013. It means that the Draft email has either been opened and is therefore "in use" or the preview panel is open and the Draft email is highlighted in the drafts folder. In Outlook 2010, you don‘t get any error if the Draft email is highlighted in the folder and the preview panel is open. To fix the problem, turn off your preview pane and do not leave any email (to be sent) highlighted. Thanks to Paul for his assistance in debugging the problem. Mark
Comment by Paul Hetherington on Tue, Apr 3rd, 2018 at 5:15 PM
Receiving the same error as Alexander but only on the last email in drafts to be sent (using the above code shown in the Send_All_Draft_Emails) [Win7 64bit, Outlook 2013]
Comment by Mark Fonseca on Sat, Feb 17th, 2018 at 12:55 PM
Fixed the issue mentioned by Alexander Kos where if a draft email does not contain TO, CC, or a BCC address, it would error.
Comment by Alexander Kos on Wed, Feb 7th, 2018 at 7:52 PM
Run-time error There must be at least one name or contact group in to,cc, or Bcc box. There is a correct email in To: Win7 Professional 64 bit, 32 bit Outlook Professional Plus 2010
Comment by Nikki on Wed, Oct 4th, 2017 at 6:40 PM
VERY HELPFUL! THANK YOU!
Name
Email
Security Code Security Code

Subscribe to Knowledge Base

Get notified when new articles are added to the knowledge base.