Solved

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

Posted on 2013-01-18
1
1,991 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

If you don't know how to downgrade, my instructions below should be helpful.
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

773 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