我在下面的Outlook VBA中创建了一个宏,回复时将发件人的第一个名称添加到问候语中,为正文添加一些文本,并在我想要的字体中添加签名 .
我需要帮助的是让宏拉出发件人的所有名称,为他们分配一个值,然后我可以将其放在电子邮件正文的其他位置 . 如果无法做到这一点,我会满足于将所有的名字都放入问候语中,尽管最好能够移动名字 .
示例:sender是Name1; Name2
目前,这个宏只会拉出Name1(给出"Dear Name1,"),但我想至少得到"Dear Name1 and Name2," . 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
1 回答
给定一个字符串“First Last”,然后像这样得到字符串的右侧
使用代码中的格式:
如果文本中有空格,则InStr返回位置 . https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/instr-function
原始邮件有一个发件人 . ReplyAll有收件人,包括原始邮件发件人 .