KrisVercammen
Gebruiker
- Lid geworden
- 24 jun 2019
- Berichten
- 6
Wanneer ik onderstaande uitvoer in Outlook, krijg ik steeds foutmelding, terwijl ik niets wijzigde en het oorspronkelijk wel alle mails uit "Drafts" verstuurde.
'Declare Sleep API
Private Declare Sub Sleep Lib "kernel32" (ByVal nMilliseconds As Long)
Sub SendAllDrafts()
' Send the messages in the Drafts folder (ignore any subfolders)
If MsgBox("Are you sure you want to send ALL the items in * Drafts folder?", _
vbQuestion + vbYesNo) <> vbYes Then Exit Sub
Dim fldDraft As MAPIFolder
Dim msg As Outlook.MailItem
Dim intCount As Integer
Set fldDraft = Outlook.Application.Folders("Drafts")
intCount = 0
Do While fldDraft.Items.Count > 0
Set msg = fldDraft.Items(1)
msg.Send
Sleep 500
intCount = intCount + 1
Loop
If Not (msg Is Nothing) Then Set msg = Nothing
Set fldDraft = Nothing
MsgBox intCount & " messages sent", vbInformation + vbOKOnly
End Sub
'Declare Sleep API
Private Declare Sub Sleep Lib "kernel32" (ByVal nMilliseconds As Long)
Sub SendAllDrafts()
' Send the messages in the Drafts folder (ignore any subfolders)
If MsgBox("Are you sure you want to send ALL the items in * Drafts folder?", _
vbQuestion + vbYesNo) <> vbYes Then Exit Sub
Dim fldDraft As MAPIFolder
Dim msg As Outlook.MailItem
Dim intCount As Integer
Set fldDraft = Outlook.Application.Folders("Drafts")
intCount = 0
Do While fldDraft.Items.Count > 0
Set msg = fldDraft.Items(1)
msg.Send
Sleep 500
intCount = intCount + 1
Loop
If Not (msg Is Nothing) Then Set msg = Nothing
Set fldDraft = Nothing
MsgBox intCount & " messages sent", vbInformation + vbOKOnly
End Sub