good point, need to change to msg.recipients(1).nameQuote:
SenderName is on the original message not the reply, so this returns nothing.
Printable View
good point, need to change to msg.recipients(1).nameQuote:
SenderName is on the original message not the reply, so this returns nothing.
Thanks for helping guys, but no luck. Still getting an error.
on which line? what error?Quote:
Still getting an error.
Again reviving this thread. Can any expert help with a code to insert a Dear 'First Name' in a new mail / reply once the recipients are in the TO field?
post the code you have so far
Try the following, which is about as close as you can get.
Code:Sub AddName()
Dim olEmail As Outlook.MailItem
Dim olInsp As Outlook.Inspector
Dim wdDoc As Object
Dim oRng As Object
Dim vName As Variant
On Error Resume Next
Set olEmail = ActiveInspector.CurrentItem
If Not olEmail.To = vbNullString Then
With olEmail
.BodyFormat = olFormatHTML
vName = Split(.To, Chr(32))
Set olInsp = .GetInspector
Set wdDoc = olInsp.WordEditor
Set oRng = wdDoc.Range(0, 0)
oRng.Text = "Dear " & vName(0) & vbCr
oRng.collapse 0
oRng.Select
.Display
End With
Else
MsgBox "There is no recipient in the 'To' field'"
End If
End Sub