Solved

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

Posted on 2013-01-18
1
2,083 Views
Last Modified: 2013-01-23
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
Comment
Question by:aehrenwo
1 Comment
 
LVL 8

Accepted Solution

by:
R_Edwards earned 200 total points
ID: 38792687
#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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
Find out what you should include to make the best professional email signature for your organization.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question