#1
|
|||
|
|||
Send selected drafts VBA
Hi guys
I've seen a lot of complicated VBAs to achieve sending selected drafts, however I'm working on this at the moment... I'm stuck at this part that's not working: For Each Draftmail In xSelection Draftmail.Send Next Any thoughts would be really welcome! Full code is below. Thanks James Sub SendSelectedDraftEmails() Dim xSelection As Selection Dim xPromptStr As String Dim xYesOrNo As Integer Dim i As Long Set xSelection = Outlook.Application.ActiveExplorer.Selection If xSelection.count > 0 Then xPromptStr = "Are you sure to send the selected " & xSelection.count & " draft item(s)?" xYesOrNo = MsgBox(xPromptStr, vbQuestion + vbYesNo) If xYesOrNo = vbYes Then For i = xSelection.count To 1 Step -1 For Each Draftmail In xSelection Draftmail.Send Next Next MsgBox "Successfully sent " & xSelection.count & " messages" End If Else MsgBox "No drafts selected!" End If End Sub |
#2
|
|||
|
|||
Hi guys
Nevermind the above, I've come up with a workaround. Essentially I have ended up with a macro that sends all the drafts in a particular drafts folder (in this case, Merge Tools). I was also getting an 'inline' error whilst using this because I was viewing the draft it was trying to send, so I made it switch to the Inbox view before sending the drafts. Here's the code for anyone who wants it Sub SendAllMergeToolsDrafts() If MsgBox("Are you sure you want to send ALL the items in your Merge Tools drafts folder?", _ vbQuestion + vbYesNo) <> vbYes Then Exit Sub Dim myNamespace As Outlook.NameSpace 'Change view to Inbox to avoid inline error Set myNamespace = Application.GetNamespace("MAPI") 'Change view to Inbox to avoid inline error Set Application.ActiveExplorer.CurrentFolder = _ myNamespace.GetDefaultFolder(olFolderInbox) 'Change view to Inbox to avoid inline error Dim fldDraft As MAPIFolder, msg As Outlook.MailItem, intCount As Integer Set fldDraft = Outlook.GetNamespace("MAPI").GetDefaultFolder(olFo lderDrafts).Folders("Merge Tools") 'Sends all drafts in the Merge Tools folder only intCount = 0 Do While fldDraft.Items.count > 0 Set msg = fldDraft.Items(1) msg.Send intCount = intCount + 1 Loop If Not (msg Is Nothing) Then Set msg = Nothing Set fldDraft = Nothing MsgBox intCount & " messages sent", vbInformation + vbOKOnly End Sub |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
VBA to change 'From' on drafts | JamesWood | Outlook | 5 | 02-15-2021 05:10 AM |
word 2016 won't change to drafts for default view | infonutt | Word | 0 | 07-21-2017 10:31 AM |
My draft message gets deleted from drafts when I send it? | Bansaw | Outlook | 2 | 07-28-2011 08:45 AM |
autosaving drafts with digital signature in outlook 2010 | lvovich | Outlook | 0 | 04-11-2011 12:40 AM |
Sent Items in Saved in Drafts | trish@25by7.com | Outlook | 1 | 11-05-2010 02:33 AM |