Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto send draft in outlook

Status
Not open for further replies.

Carrion

Technical User
Jul 26, 2002
27
US
I am looking for a piece of code that will send messages saved in my draft folder in outlook, without having to manually go into the folder and do it myself. I am not sure where to begin. I am actually using Access to put the file in the draft folder. So ideally i would like to not have to leave access, but it i need to be in outlook to make it happen, i can live with that.
 
You'll probably get the Outlook security popup when sending.

Code:
Sub Send_Drafts()
   Dim ns As Outlook.NameSpace
   Dim drafts As Outlook.MAPIFolder
   Dim i As Integer
   
   Set ns = GetNamespace("MAPI")
   Set drafts = ns.GetDefaultFolder(olFolderDrafts)
   
   For i = drafts.Items.Count To 1 Step -1
      drafts.Items(i).Send
   Next i
End Sub
 
This will bypass the security prompt, but you'll need to download Redemption for Outlook.

Code:
' Don't forget to add a reference to the Redemption Outlook Library

Sub Send_Drafts()
   Dim ns As Outlook.NameSpace
   Dim drafts As Outlook.MAPIFolder
   Dim mail_item As Object

   Set ns = GetNamespace("MAPI")
   Set drafts = ns.GetDefaultFolder(olFolderDrafts)
   
   For i = drafts.Items.Count To 1 Step -1
      Set mail_item = New Redemption.SafeContactItem
      
      mail_item.Item = drafts.Items(i)
      mail_item.Send
   Next i
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top