Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 26 of 26

Thread: Insert Recipient's name in reply

  1. #21
    SenderName is on the original message not the reply, so this returns nothing.
    good point, need to change to msg.recipients(1).name

  2. #22
    VBAX Regular
    Joined
    Dec 2013
    Posts
    7
    Location
    Thanks for helping guys, but no luck. Still getting an error.

  3. #23
    Still getting an error.
    on which line? what error?

  4. #24
    VBAX Regular
    Joined
    Dec 2013
    Posts
    7
    Location
    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?

  5. #25
    post the code you have so far

  6. #26
    Try the following, which is about as close as you can get.

    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
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •