我已在Outlook VBA下创建了一个宏,该回复的发件人名添加到了问候语中,为主体添加了一些文本,并在我想要的字体。带有个人收件人姓名(原始电子邮件的发件人姓名)的Outlook回复
我需要帮助的是让宏拉取发件人的所有名称,为他们分配一个值,然后我可以将其放置在电子邮件正文的其他地方。如果做不到这一点,我会解决所有问题的名字,尽管能够移动名字是最好的选择。
例如:发件人是名1,名称2
目前,该宏将仅拉出名1(给“亲爱的名称1”),但 我想获得到“亲爱的NAME 1和NAME,”至少是。 Best将能够在问候语中使用Name1,然后将Name2放置在文本的正文中。
我相信我已经把这个尽我所能,并且现在请求专家帮忙!谢谢!!
Sub AutoAddGreetingtoReply()
Dim oMail As MailItem
Dim oReply As MailItem
Dim GreetTime As String
Dim strbody As String
Dim SigString As String
Dim Signature As String
Dim R As Outlook.Recipient
Dim strGreetName As String
Select Case Application.ActiveWindow.Class
Case olInspector
Set oMail = ActiveInspector.CurrentItem
Case olExplorer
Set oMail = ActiveExplorer.Selection.Item(1)
End Select
strbody = "<H3><B></B></H3>" & _
"<br><br><B></B>" & _
"Please visit this website to view your transactions.<br>" & _
"Let me know if you have problems.<br>" & _
"<A HREF=""http://www.google.com"">Questions</A>" & _
"<br><br>Thank you"
SigString = Environ("appdata") & _
"\Microsoft\Signatures\90 Days.htm"
On Error Resume Next
If Dir(SigString) <> "" Then
strGreetName = Left$(oMail.SenderName, InStr(1, oMail.SenderName, " ") - 1)
End If
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
Set oReply = oMail.ReplyAll
With oReply
.CC = ""
.HTMLBody = "<Font Face=calibri>Dear " & strGreetName & "," & R1 & strbody & "<br>" & Signature
.Display
End With
End Sub
On Error Resume Next阻碍了学习。 http://www.cpearson.com/Excel/ErrorHandling.htm – niton