Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2469
  • Last Modified:

Adding First Name of Recipient for Reply/Reply All in Outlook 2010

Is there a simple VBA code that can be used to always put the "First Name" of the person in the body of a email when replying?

i.e ... a line at the top of the new message that was simply [First Name],

I support a helpdesk and this would save me a tremendous amount of time. I would be okay if it was a reply all scenario and there was more than one name if it just defaulted to the first person in the From field in the original message.  I assume it would leverage the info from the profile in the Global Address Book for my company.

I want it to execute anytime I reply or reply all to any message.

Let me know how complex this might be.

Thanks

Adam
0
aehrenwo
Asked:
aehrenwo
1 Solution
 
R_EdwardsCommented:
#All credit goes to Lars Vogel#

I had the same question a while back and found this one night after killing my brain.

if you know how to create Macro's in Outlook this will be easy for you, if not i recommend visiting Lars' website http://www.vogella.com/articles/MicrosoftOutlookMacros/article.html

From Lars Vogul Blog:

The following macro describes how you can extract information from the email and create a corresponding message in your email text. For example if you are writting to Jim.Test@example.com you can create a text in your email "Hi Jim,....Best regards, Lars" and place the cursor in the right place to start typing.

The following macro reads all email addresses in the To part of the email. Then is extracts the part before the first "." assumes that this is the first name and writes Hello firstname1, firstname2,...

It also puts in "Best regards, Lars" and places the cursor on the right position to reply. The macro allows also to set a defined delay in sending out the email.

Sub Generic(greeting, byebye, myname, includeCC, category, delay, text)
   
    Dim olApp As Outlook.Application
   
    Set olApp = Outlook.Application

    If TypeName(Application.ActiveInspector.CurrentItem) = "MailItem" Then
        Call mailreply(greeting, byebye, myname, includeCC, category, delay, text)
    End If
   
End Sub


Sub mailreply(greeting, byebye, myname, includeCC, category, delay, text)
   
    Dim objMail As Outlook.MailItem
   
    Set objMail = Application.ActiveInspector.CurrentItem
   
    With objMail
       'Set body format to HTML
       Dim arry As String
       Dim help As String
       
       Dim email, vorname As Variant
 
       
       Dim cced As Variant
       Dim anrede As Variant
       Dim size As Integer
       
       cced = Split(.CC, ";")

       
       email = Split(.To, ";")
       Dim Anzahl As Integer
       
       ' Now get the names of the persons which are in the email
       
       Anzahl = UBound(email)
       
        first = True
        For I = 0 To Anzahl
       
            'If Not email(i) = "Vogel, Lars;" Then
           
             vorname = Split(email(I), ",")
             
           'If size(vorname()) <> 0 Then
             
            If UBound(vorname) > 0 Then
            If first Then
            anrede = vorname(1)
            first = False
            Else
            anrede = anrede & " / " & vorname(1)
        End If

        End If
       ' End If
       
       
       
       Next I
       
       If includeCC = "1" Then
       
       ' Now get the names of the persons which are cc'ed
       
       Anzahl = UBound(cced)
       
        first = True
       For I = 0 To Anzahl
       If Not email(I) = "Vogel, Lars" Then
        vorname = Split(cced(I), ",")
       
        If UBound(vorname) > 0 Then
        If first Then
        anrede = anrede & " ," & vbNewLine & "cc:" & vorname(1)
        first = False
       
         Else
        anrede = anrede & " / " & vorname(1)
        End If

        End If
        End If
       
       Next I
       
        Else
             anrede = anrede & " ,"
        End If
       
       .Body = greeting & anrede & vbNewLine & vbNewLine & text & vbNewLine & vbNewLine & byebye & myname & vbNewLine & vbNewLine & "---------------------------------------" & vbNewLine & .Body
       
       .Display
       
       
    End With
    objMail.Categories = category
       
    'End If
    SendKeys "{DOWN}"
    SendKeys "{DOWN}"
   
End Sub

Sub Reply_Text_English_Urgent()
    Call Generic("Hi", "Best regards, ", "Lars", 0, "Business", False, "")
End Sub


Again this is not my work and all credit goes to lars Vogul.

hope this helps
-=Richard
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now