2016-07-05 91 views
0

我試圖實現一個宏,將回復所選電子郵件的發件人與共享模板。Outlook宏 - 回覆模板發件人

目前我有兩個獨立的宏。

  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, "[email protected]") = 1 Then 
strAccount = "[email protected]" 
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 protected]" 
replyEmail.Display 
End Sub 

任何幫助,將不勝感激!謝謝!

+0

意識到這個不是很清楚,所以我稍微改了一下。 – JMar

回答

0

要確定姓名(或名稱)來進行回覆,不一定發件人

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 protected]" 
replyEmail.Recipients.ResolveAll 
replyEmail.Display 

Set origEmail = Nothing 
Set replyEmail = Nothing 

End Sub 
相關問題