【问题标题】:Outlook Macro - Reply to sender with templateOutlook 宏 - 使用模板回复发件人
【发布时间】:2016-07-05 09:49:50
【问题描述】:

我正在尝试实现一个宏,该宏将使用共享模板回复所选电子邮件的发件人。

目前我有两个单独的宏。

  1. 将回复发件人并插入他们的地址。
  2. 将使用模板回复(但不插入发件人地址)。

我想知道是否可以将两者结合来实现我的目标? 这样当您运行宏时,它会使用模板回复电子邮件,并填写原始发件人的地址和主题?

我对 VBA 的了解非常有限,所以我不确定它是否/如何可能。这就是我所拥有的。

1:

Public Sub AccountSelection()
Dim oAccount As Outlook.Account
Dim strAccount As String
Dim olNS As Outlook.NameSpace
Dim objMsg, oMail As MailItem

Set olNS = Application.GetNamespace("MAPI")
Set objMsg = ActiveExplorer.Selection.Item(1).Reply

If TypeName(ActiveExplorer.Selection.Item(1)) = "MailItem" Then
 Set oMail = ActiveExplorer.Selection.Item(1)

 On Error Resume Next

For Each Recipient In oMail.Recipients
 strRecip = Recipient.Address & ";" & strRecip
Next Recipient

If InStr(strRecip, "alias@domain1.com") = 1 Then
strAccount = "alias@domain1.com"
Else
End If

For Each oAccount In Application.Session.Accounts
  If oAccount.DisplayName = strAccount Then
     objMsg.SendUsingAccount = oAccount

       Else

  End If
Next

  objMsg.Display

Else

End If

Set objMsg = Nothing
Set olNS = Nothing
End Sub

2.

Sub TacReply()
Dim origEmail As MailItem
Dim replyEmail As MailItem
Set origEmail = Application.ActiveExplorer.Selection(1)
Set replyEmail = Application.CreateItemFromTemplate("S:\Share\TWGeneral.oft")
replyEmail.HTMLBody = replyEmail.HTMLBody & origEmail.Reply.HTMLBody
replyEmail.SentOnBehalfOfName = "email@domain.com"
replyEmail.Display
End Sub

任何帮助将不胜感激!谢谢!

【问题讨论】:

  • 意识到这不是很清楚,所以我稍微改写了一下。

标签: vba templates outlook macros reply


【解决方案1】:

确定发送回复的姓名,不一定是发件人

origEmail.Reply.To

.

Sub TacReply()

Dim origEmail As mailItem
Dim replyEmail As mailItem

Set origEmail = ActiveExplorer.Selection(1)
Set replyEmail = CreateItemFromTemplate("S:\Share\TWGeneral.oft")

replyEmail.To = origEmail.Reply.To

replyEmail.HTMLBody = replyEmail.HTMLBody & origEmail.Reply.HTMLBody
replyEmail.SentOnBehalfOfName = "email@domain.com"
replyEmail.Recipients.ResolveAll
replyEmail.Display

Set origEmail = Nothing
Set replyEmail = Nothing

End Sub

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-08
    • 2012-02-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多