vba Outlook 对电子邮件的回复或全部回复
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31817632/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Outlook Reply or ReplyAll to an Email
提问by Zheng Yi Chew
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
objMail.To = "[email protected]"
objMail.cc = "[email protected]"
objMail.Subject = "Mail test"
objMail.HTMLBody = "This is my message"
unload me
objMail.Display
Set objMail = Nothing
Set objOutlook = Nothing
I am trying to add in another function that help to reply a selected email but can't figure out how I can mix this with Item As Outlook.MailItemI understand that replying an email will require that.
我正在尝试添加另一个功能来帮助回复选定的电子邮件,但无法弄清楚如何将其与Item As Outlook.MailItem我了解回复电子邮件需要这样做。
So I would like to know how I can add on so that I can select an email, execute the macro and it will input the recipient email into objMail.Toand recipient's body into objMail.HTMLBody
所以我想知道如何添加以便我可以选择电子邮件,执行宏并将收件人电子邮件输入到objMail.To收件人的正文中objMail.HTMLBody
回答by 0m3r
To simply Replyor ReplyAllselected messages try the following.
Option Explicit
Sub ReplyMSG()
Dim olItem As Outlook.MailItem
Dim olReply As MailItem ' Reply
Dim olRecip As Recipient ' Add Recipient
For Each olItem In Application.ActiveExplorer.Selection
Set olReply = olItem.ReplyAll
Set olRecip = olReply.Recipients.Add("Email Address Here") ' Recipient Address
olRecip.Type = olCC
olReply.HTMLBody = "Hello, Thank you. " & vbCrLf & olReply.HTMLBody
olReply.Display
'olReply.Send
Next olItem
End Sub
To hide the recipient use BCCExample
要隐藏收件人使用密件抄送示例
olRecip.Type = olBcc
olRecip.Type = olBcc
To add multiple recipient just add
要添加多个收件人只需添加
Set olRecip = olReply.Recipients.Add("Email Here")
Set olRecip = olReply.Recipients.Add("Email Here")
Set olRecip = olReply.Recipients.Add("Email Here")
With out Recipient try the following.
如果没有收件人,请尝试以下操作。
Option Explicit
Sub ReplyMSG()
Dim olItem As Outlook.MailItem
Dim olReply As MailItem ' Reply
For Each olItem In Application.ActiveExplorer.Selection
Set olReply = olItem.ReplyAll
olReply.HTMLBody = "Hello, Thank you. " & vbCrLf & olReply.HTMLBody
olReply.Display
'olReply.Send
Next olItem
End Sub

