【发布时间】:2016-07-05 09:49:50
【问题描述】:
我正在尝试实现一个宏,该宏将使用共享模板回复所选电子邮件的发件人。
目前我有两个单独的宏。
- 将回复发件人并插入他们的地址。
- 将使用模板回复(但不插入发件人地址)。
我想知道是否可以将两者结合来实现我的目标? 这样当您运行宏时,它会使用模板回复电子邮件,并填写原始发件人的地址和主题?
我对 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