跳到主要內容

如何在Outlook中自動回復原始電子郵件?

通常,當我們創建規則自動依賴外出電子郵件時,但正文中的原始郵件將不會被包含在內。 如何在 Outlook 中自動信賴帶有原始消息的電子郵件? 這篇文章,我將討論一段VBA代碼,以幫助您在Outlook中盡快完成這項工作。

使用 VBA 代碼在 Outlook 中自動回复帶有原始消息的電子郵件


使用 VBA 代碼在 Outlook 中自動回复帶有原始消息的電子郵件

普通的 Outlook 規則無法幫助您處理工作,但是,使用以下 VBA 代碼,您可以快速輕鬆地完成此工作。 請按如下操作:

1。 按住 ALT + F11 鍵打開 Microsoft Visual Basic for Applications 窗口。

2。 在 Microsoft Visual Basic for Applications 窗口,雙擊 這個展望會議n從 Project1(VbaProject.OTM) 窗格以打開模式,然後將以下代碼複製並粘貼到空白模塊中。

VBA代碼:自動回复帶有原始消息的電子郵件:

Public WithEvents xlItems As Outlook.Items
Private Sub Application_Startup()
    Set xlItems = Session.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub xlItems_ItemAdd(ByVal objItem As Object)
Dim xlReply As MailItem
Dim xStr As String
If objItem.Class <> olMail Then Exit Sub
Set xlReply = objItem.Reply
With xlReply
     xStr = "<p>" & "Hi, Your email has been received. Thank you!" & "</p>"
     .HTMLBody = xStr & .HTMLBody
     .Send
End With
End Sub 

3。 然後保存並關閉代碼窗口,關閉或重新啟動Outlook以使VBA代碼生效。 現在,當您收到電子郵件時,Outlook 將發送一條自動回复,其中包含原始郵件,如下圖所示:


最佳辦公生產力工具

Kutools for Outlook - 超過 100 種強大的功能可增強您的 Outlook

🤖 人工智慧郵件助手: 具備人工智慧魔力的即時專業電子郵件——一鍵天才回覆、完美語調、多語言掌握。輕鬆改變電子郵件! ……

📧 電子郵件自動化: 外出(適用於 POP 和 IMAP)  /  安排發送電子郵件  /  發送電子郵件時按規則自動抄送/密件副本  /  自動轉送(進階規則)   /  自動添加問候語   /  自動將多收件者電子郵件拆分為單獨的訊息 ...

📨 電子郵件管理: 輕鬆回憶電子郵件  /  按主題和其他人阻止詐騙電子郵件  /  刪除重複的電子郵件  /  進階搜索  /  合併資料夾 ...

📁 附件專業版批量保存  /  批量分離  /  批量壓縮  /  自動保存   /  自動分離  /  自動壓縮 ...

🌟 介面魔法: 😊更多又漂亮又酷的表情符號   /  使用選項卡式視圖提高 Outlook 工作效率  /  最小化 Outlook 而不是關閉 ...

👍 一鍵奇蹟: 使用傳入附件回覆全部  /   反網路釣魚電子郵件  /  🕘顯示寄件者的時區 ...

👩🏼‍🤝‍👩🏻 通訊錄和行事曆: 從選定的電子郵件中大量新增聯絡人  /  將聯絡人群組拆分為各組  /  刪除生日提醒 ...

超過 100特點 等待您的探索! 按此處了解更多。

閱讀更多       免費下載      購買
 

 

Comments (8)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hello

I have another question. How can I change the Session.GetDefaultFolder(olFolderInbox).Items. I work with several email accounts and I need this response just from 3 of them.

Thank you in advance
This comment was minimized by the moderator on the site
Hi,
I have another question:
How do I apply this rule to a specific selected sender only
Session.GetDefaultFolder(olFolderInbox).Items
This comment was minimized by the moderator on the site
HiI have the same question : how do I apply this rule to selected sender only ?br
This comment was minimized by the moderator on the site
Hello, Damien,For specifying some senders when auto reply, please apply the below code:

<div data-tag="code">Public WithEvents xlItems As Outlook.Items
Private Sub Application_Startup()
Set xlItems = Session.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub xlItems_ItemAdd(ByVal objItem As Object)
Dim xlReply As MailItem
Dim xStr As String
Dim xSenderAddr As String
On Error Resume Next
If objItem.Class <> olMail Then Exit Sub
xSenderAddr = "," 'type your own sender emials here, separate them by commas.
If objItem.Sender.Type = "EX" Then
If InStr(xSenderAddr, objItem.Sender.GetExchangeUser.PrimarySmtpAddress) = 0 Then Exit Sub
Else
If InStr(xSenderAddr, objItem.Sender.Address) = 0 Then Exit Sub
End If
Set xlReply = objItem.Reply
With xlReply
xStr = "<p>" & "Hi, Your email has been received. Thank you!" & "</p>"
.HTMLBody = xStr & .HTMLBody
.Send
End With
End SubPlease try, hope it can help you!
This comment was minimized by the moderator on the site
Hi , I've try this , but wouldn't work (:
This comment was minimized by the moderator on the site
How can you modify this to only run if there is a keyword in the message of the body?
This comment was minimized by the moderator on the site
I have the same question, did you figure it out?
This comment was minimized by the moderator on the site
try thisDim olMail As object
If (olMail.Subject Like "*Place_Keyword_here(Leave_doublequotes_and_asteriscs)*") Then
CodeEnd if
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations