如何在Outlook中一次发送多个草稿?
现在,如果您的“草稿”文件夹中有多条草稿消息,则希望一次发送一次,而不是一一发送。 您如何在Outlook中快速轻松地处理这项工作?
使用VBA代码一次在Outlook中发送所有草稿邮件
以下VBA代码可以帮助您立即从“草稿”文件夹发送所有或选定的草稿电子邮件,请这样做:
1。 按住 ALT + F11 键打开 Microsoft Visual Basic应用程序 窗口。
2。 然后点击 插页 > 模块,将以下代码复制并粘贴到打开的空白模块中,请参见屏幕截图:
VBA代码:在Outlook中一次发送所有草稿电子邮件:
Sub SendAllDraftEmails()
Dim xAccount As Account
Dim xDraftFld As Folder
Dim xItemCount As Integer
Dim xCount As Integer
Dim xDraftsItems As Outlook.Items
Dim xPromptStr As String
Dim xYesOrNo As Integer
Dim i As Long
Dim xCurFld As Folder
Dim xTmpFld As Folder
On Error Resume Next
xItemCount = 0
xCount = 0
Set xTmpFld = Nothing
Set xCurFld = Application.ActiveExplorer.CurrentFolder
For Each xAccount In Outlook.Application.Session.Accounts
Set xDraftFld = xAccount.DeliveryStore.GetDefaultFolder(olFolderDrafts)
xItemCount = xItemCount + xDraftFld.Items.Count
If xDraftFld.EntryID = xCurFld.EntryID Then
Set xTmpFld = xCurFld.Parent
End If
Next xAccount
Set xDraftFld = Nothing
If xItemCount > 0 Then
xPromptStr = "Are you sure to send out all the drafts?"
xYesOrNo = MsgBox(xPromptStr, vbQuestion + vbYesNo, "Kutools for Outlook")
If xYesOrNo = vbYes Then
If Not xTmpFld Is Nothing Then
Set Application.ActiveExplorer.CurrentFolder = xTmpFld
End If
VBA.DoEvents
For Each xAccount In Outlook.Application.Session.Accounts
Set xDraftFld = xAccount.DeliveryStore.GetDefaultFolder(olFolderDrafts)
Set xDraftsItems = xDraftFld.Items
For i = xDraftsItems.Count To 1 Step -1
If xDraftsItems.Item(i).Recipients.Count <> 0 Then
xDraftsItems.Item(i).sEnd
xCount = xCount + 1
End If
Next
Next xAccount
VBA.DoEvents
Set Application.ActiveExplorer.CurrentFolder = xCurFld
MsgBox "Successfully sent " & xCount & " messages", vbInformation, "Kutools for Outlook"
End If
Else
MsgBox "No Drafts!", vbInformation + vbOKOnly, "Kutools for Outlook"
End If
End Sub
3。 然后保存代码,然后按 F5 键以运行此代码,将弹出一个提示框,提醒您是否发送所有草稿,请单击 USB MIDI(XNUMX通道),请参见屏幕截图:
4。 然后会弹出一个对话框,提醒您已发送了多少电子邮件草稿,请参见屏幕截图:
5。 然后点击 OK 按钮中的所有电子邮件 草稿箱 文件夹将立即发送,请参见屏幕截图:
笔记:
1.上面的代码将发送Outlook中所有帐户的所有电子邮件草稿。
2.如果您只想从“草稿”文件夹发送一些特定的电子邮件,请应用以下VBA代码:
VBA代码:从“草稿”文件夹发送选定的电子邮件:
Sub SendSelectedDraftEmails()
Dim xSelection As Selection
Dim xPromptStr As String
Dim xYesOrNo As Integer
Dim i As Long
Dim xAccount As Account
Dim xCurFld As Folder
Dim xDraftsFld As Folder
Dim xTmpFld As Folder
Dim xArr() As String
Dim xCount As Integer
Dim xMail As MailItem
On Error Resume Next
xCount = 0
Set xTmpFld = Nothing
Set xCurFld = Application.ActiveExplorer.CurrentFolder
For Each xAccount In Outlook.Application.Session.Accounts
Set xDraftsFld = xAccount.DeliveryStore.GetDefaultFolder(olFolderDrafts)
If xDraftsFld.EntryID = xCurFld.EntryID Then
Set xTmpFld = xCurFld.Parent
End If
Next xAccount
If xTmpFld Is Nothing Then
MsgBox "The current folder is not a draft folder", vbInformation, "Kutools for Outlook"
Exit Sub
End If
Set xSelection = Outlook.Application.ActiveExplorer.Selection
If xSelection.Count > 0 Then
xPromptStr = "Are you sure to send out the selected " & xSelection.Count & " draft item(s)?"
xYesOrNo = MsgBox(xPromptStr, vbQuestion + vbYesNo, "Kutools for Outlook")
If xYesOrNo = vbYes Then
ReDim xArr(xSelection.Count - 1)
For i = 1 To xSelection.Count
xArr(i - 1) = xSelection.Item(i).EntryID
Next
Set Application.ActiveExplorer.CurrentFolder = xTmpFld
VBA.DoEvents
For i = 0 To UBound(xArr)
Set xMail = Application.Session.GetItemFromID(xArr(i))
If xMail.Recipients.Count <> 0 Then
xMail.sEnd
xCount = xCount + 1
End If
Next
VBA.DoEvents
Set Application.ActiveExplorer.CurrentFolder = xCurFld
MsgBox "Successfully sent " & xCount & " messages", vbInformation, "Kutools for Outlook"
End If
Else
MsgBox "No items selected!", vbInformation, "Kutools for Outlook"
End If
End Sub
相关文章:
如何通过Outlook从Excel向列表发送个性化大量电子邮件?
如何在Outlook中未知的情况下向多个收件人发送电子邮件?
最佳办公生产力工具
Kutools for Outlook - 超过 100 种强大功能可增强您的 Outlook
🤖 人工智能邮件助手: 具有人工智能魔力的即时专业电子邮件——一键天才回复、完美语气、多语言掌握。轻松改变电子邮件! ...
📧 电子邮件自动化: 外出(适用于 POP 和 IMAP) / 安排发送电子邮件 / 发送电子邮件时按规则自动抄送/密件抄送 / 自动转发(高级规则) / 自动添加问候语 / 自动将多收件人电子邮件拆分为单独的消息 ...
📨 电子邮件管理: 轻松回忆电子邮件 / 按主题和其他人阻止诈骗电子邮件 / 删除重复的电子邮件 / 高级搜索 / 合并文件夹 ...
📁 附件专业版: 批量保存 / 批量分离 / 批量压缩 / 自动保存 / 自动分离 / 自动压缩 ...
🌟 界面魔法: 😊更多又漂亮又酷的表情符号 / 使用选项卡式视图提高 Outlook 工作效率 / 最小化 Outlook 而不是关闭 ...
👍 一键奇迹: 使用传入附件回复全部 / 反网络钓鱼电子邮件 / 🕘显示发件人的时区 ...
👩🏼🤝👩🏻 通讯录和日历: 从选定的电子邮件中批量添加联系人 / 将联系人组拆分为各个组 / 删除生日提醒 ...
超过 100特点 等待您的探索! 单击此处了解更多。