PDA

View Full Version : How Can I Reply to Email with First Name Only?



VBE313
12-24-2019, 09:10 AM
How can I reply to someone by just having their first name filled out? Using nameExample for example.


Sub ReplyMSG()
Dim nameExample as String
Dim testNum As Double
Dim olItem As Outlook.MailItem
Dim olInsp As Outlook.Inspector
Dim wdDoc As Object
Dim oRng As Object
Dim olReply As MailItem ' Reply
testNum = InputBox("Enter quote number", "Quote Number", 1)
For Each olItem In Application.ActiveExplorer.Selection
Set olReply = olItem.ReplyAll
With olReply
Set olInsp = .GetInspector
Set wdDoc = olInsp.WordEditor
Set oRng = wdDoc.Range(0, 0)
oRng.Text = "Hi " & nameExample & "Please refer to this RFQ as Quote #" & testNum
End With
olReply.Display
DoEvents
Next olItem
Set olReply = Nothing
Set olItem = Nothing
Set olInsp = Nothing
Set wdDoc = Nothing
Set oRng = Nothing
End Sub

gmayor
12-24-2019, 10:19 PM
Maybe something like

Sub ReplyMSG()
Dim nameExample As String
Dim testNum As Double
Dim olItem As Outlook.MailItem
Dim olInsp As Outlook.Inspector
Dim wdDoc As Object
Dim oRng As Object
Dim olReply As MailItem ' Reply
On Error Resume Next
testNum = InputBox("Enter quote number", "Quote Number", 1)
For Each olItem In Application.ActiveExplorer.Selection
nameExample = Split(olItem.SenderName, Chr(32))(0)
Set olReply = olItem.ReplyAll
With olReply
Set olInsp = .GetInspector
Set wdDoc = olInsp.WordEditor
Set oRng = wdDoc.Range(0, 0)
oRng.Text = "Hi " & nameExample & vbCr & vbCr & _
"Please refer to this RFQ as Quote #" & testNum
End With
olReply.Display
testNum = testNum + 1
DoEvents
Next olItem
Set olReply = Nothing
Set olItem = Nothing
Set olInsp = Nothing
Set wdDoc = Nothing
Set oRng = Nothing
End Sub

VBE313
12-25-2019, 08:34 AM
God Bless you! thank you Graham!