2016-07-05 17 views
0

共有テンプレートを使用して、選択した電子メールの送信者に返信するマクロを実現しようとしています。Outlookマクロ - テンプレートを使用して送信者に返信する

私は2つの別々のマクロを持っています。

  1. 送信者に返信し、そのアドレスを挿入します。
  2. テンプレートで返信します(ただし、送信者アドレスは挿入しません)。

目的を達成するために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 

任意の助けもいただければ幸いです!ありがとう!送信者

origEmail.Reply.To 

必ずしも、応答を送信するための名前(複数可)を決定するため

+0

これはあまり明確ではなかったので、私は少し言い換えました。 – JMar

答えて

0

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 
関連する問題