How to send All Draft in outlook by vba

MUKESHY12390

Well-known Member
Joined
Sep 18, 2012
Messages
901
Office Version
  1. 2013
  2. 2011
  3. 2010
  4. 2007
Platform
  1. Windows
Hi frnds,

I need code that willl send all Drafts in Outlook...??

please help me...!

Outlook VBA is new for me. But I am enough smart in Excel VBA.

direct or Indirect help would be appreciate... Thanks in Adance:)
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
here an outlook vba

Code:
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.
Set myDraftsFolder = myFolders("rsprebitz@idafoundation.org").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
 
Upvote 0
which office version? in 2013 its not possible

Actually, I tested your code in 2013, and it seems to work fine. Maybe you meant 2003? Even so, I tested it there too, and it seems to work fine.

By the way, the user will need to set a reference to "Microsoft Outlook Object Library"...

Code:
Visual Basic Editor > Tools > Reference > and select Microsoft Outlook Object Library

I've forgotten to mentioned the reference in the past as well. ;)

Cheers!
 
Upvote 0
nevermind its not working in Inline response mode of outlook 2013 i guess I messed up my testmachine but anyway the Exchange 2013 and Outlook 2013 needs some major fixes with next SP1 as some code got broken

I didn't forgot the reference I just haven't tested it at all in excel I've just tested it in Outlook but good to know its working there as well :)
 
Upvote 0
I didn't forgot the reference I just haven't tested it at all in excel I've just tested it in Outlook but good to know its working there as well :)

Sorry, I thought the code was going to run from within Excel... :)
 
Upvote 0
thanks.. it's working great.. HHacker and, domenic I 'll keep your Point in case of Excel:)
 
Upvote 0
It's working great...But In my Draft mail.. I have already" CC" and "TO" Recipients name But I need to add one more Recipient like -eg.(mks.yadav@jackson.com).so how can I add this
Recipient..??
OR otherwise I have to add manually for 200 Mails and it's really take lot of time..
 
Upvote 0

Forum statistics

Threads
1,216,503
Messages
6,131,020
Members
449,615
Latest member
Nic0la

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top