View Single Post
 
Old 02-15-2021, 05:13 AM
JamesWood JamesWood is offline Windows 10 Office 2019
Advanced Beginner
 
Join Date: Nov 2020
Posts: 37
JamesWood is on a distinguished road
Question 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
Reply With Quote