learningVBA321
New Member
- Joined
- Jul 10, 2017
- Messages
- 30
Hello everyone,
I have some code here that currently works to create a reply, take the sender's name, and put it in the greeting. It also adds wording for the body and then a signature. What I need to do is get Outlook to pull all the names from the sender field and be able to add them to the reply as well.
So, you have the sender as Name1; Name 2 in the from fields from the original received email (they become the To fields in the reply).
I currently get this in my reply using the code below: Dear Name1,
I want to have it get Dear Name1 but then also assign a value to Name2. One that I could either put somewhere in the body (preferable) or at least have it add to the greeting. I know I can pull them as a string, but I want to treat each name individually, as I might need to put them in a place other than just the greeting.
I got some of this from Ron DeBruin and then added my own and some other coding. Can anyone help?
Thanks!
I have some code here that currently works to create a reply, take the sender's name, and put it in the greeting. It also adds wording for the body and then a signature. What I need to do is get Outlook to pull all the names from the sender field and be able to add them to the reply as well.
So, you have the sender as Name1; Name 2 in the from fields from the original received email (they become the To fields in the reply).
I currently get this in my reply using the code below: Dear Name1,
I want to have it get Dear Name1 but then also assign a value to Name2. One that I could either put somewhere in the body (preferable) or at least have it add to the greeting. I know I can pull them as a string, but I want to treat each name individually, as I might need to put them in a place other than just the greeting.
I got some of this from Ron DeBruin and then added my own and some other coding. Can anyone help?
Thanks!
Code:
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
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"
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
Set oReply = oMail.ReplyAll
With oReply
.CC = ""
.HTMLBody = "<Font Face=calibri>Dear " & oMail.SenderName & "," & r1 & strTo & strbody & "<br>" & Signature
.Display
End With
End Sub