Consulting

Results 1 to 3 of 3

Thread: How Can I Reply to Email with First Name Only?

  1. #1
    VBAX Regular
    Joined
    Mar 2019
    Posts
    15
    Location

    How Can I Reply to Email with First Name Only?

    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

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

  3. #3
    VBAX Regular
    Joined
    Mar 2019
    Posts
    15
    Location
    God Bless you! thank you Graham!

Tags for this Thread

Posting Permissions

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