![]() |
| If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|||||||
| Tags: code, draft, messages, review, send |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
All,
I have written some VBA to loop through the items in my Drafts folder and send each one. I am not very familiar with the Outlook object model, or their properties and methods. My first inclination was to "do something" with each item in the folder, but the Send method effectively removes the item from the folder. The code below seems to work well. If I have the correct understanding, items are indexed beginning at 1, so if my Drafts folder contained 30 items, the code will execute inside the loop until all messages are sent (.Count = 0), while assuring that an item is always in scope. Do Until myDrafts.Items.Count = 0 myDrafts.Items(1).Send Loop This group has a lot more experience than I have with Outlook VBA; is this the best way to do this ... to me, it just seems there may be a better option. Take care, Chris |
| Ads |
|
#2
|
|||
|
|||
|
That approach is fine. An alternative would be a countdown For ... Next loop.
-- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "M100C" wrote in message ups.com... All, I have written some VBA to loop through the items in my Drafts folder and send each one. I am not very familiar with the Outlook object model, or their properties and methods. My first inclination was to "do something" with each item in the folder, but the Send method effectively removes the item from the folder. The code below seems to work well. If I have the correct understanding, items are indexed beginning at 1, so if my Drafts folder contained 30 items, the code will execute inside the loop until all messages are sent (.Count = 0), while assuring that an item is always in scope. Do Until myDrafts.Items.Count = 0 myDrafts.Items(1).Send Loop This group has a lot more experience than I have with Outlook VBA; is this the best way to do this ... to me, it just seems there may be a better option. Take care, Chris |
|
#3
|
|||
|
|||
|
If you are working with a collection where the number of items change as you
work with them, then you need to do a special loop: For intX = Items.Count To 1 Step -1 'Do something Next This way it always works with the last item - until there are no more items. -- Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "M100C" wrote: All, I have written some VBA to loop through the items in my Drafts folder and send each one. I am not very familiar with the Outlook object model, or their properties and methods. My first inclination was to "do something" with each item in the folder, but the Send method effectively removes the item from the folder. The code below seems to work well. If I have the correct understanding, items are indexed beginning at 1, so if my Drafts folder contained 30 items, the code will execute inside the loop until all messages are sent (.Count = 0), while assuring that an item is always in scope. Do Until myDrafts.Items.Count = 0 myDrafts.Items(1).Send Loop This group has a lot more experience than I have with Outlook VBA; is this the best way to do this ... to me, it just seems there may be a better option. Take care, Chris |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Send Email from Draft Folder | DennyP | Outlook - General Queries | 10 | June 10th 07 01:32 AM |
| Outlook Express 6 - Draft Email Icons on Desktop - Unable to use in draft form | hiten16@gmail.com | Outlook Express | 1 | October 13th 06 12:58 PM |
| Why do I have to hit send/receive to review new messages? | No3Sista | Outlook - Calandaring | 1 | October 12th 06 06:06 AM |
| draft messages don't close when outlook closes | raghav.sapra@gmail.com | Outlook - General Queries | 1 | July 13th 06 05:57 AM |
| Macro to Move Mail Messages from Draft folder to other folders | VBnovice | Outlook and VBA | 4 | June 14th 06 08:10 PM |