如何在Outlook中一次發送多個草稿?
如果您的“草稿”文件夾中有多個草稿郵件,而現在,您希望一次發送一次而不要一一發送。 您如何在Outlook中快速輕鬆地處理這項工作?
使用VBA代碼一次在Outlook中發送所有草稿郵件
以下VBA代碼可以幫助您立即發送“草稿”文件夾中的所有或選定的草稿電子郵件,請這樣做:
1。 按住 ALT + F11 鍵打開 Microsoft Visual Basic for Applications 窗口。
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 鍵以運行此代碼,將彈出一個提示框,提醒您是否發送所有草稿,請單擊 是,請參見屏幕截圖:
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特點 等待您的探索! 按此處了解更多。