+ Reply to Thread
Results 1 to 4 of 4

Thread: Change Case of recipients name when sending email

  1. #1
    Registered User
    Join Date
    02-10-2005
    Posts
    5

    Change Case of recipients name when sending email

    At work we use a program that when clicking an email address, it creates a blank email in outlook 2007 with the recipients email address in all caps like this:

    MARCUS JAMES (marcusjames44@domain.com)

    and so for every email i send i manually change the case in their name. Is there a macro that could do that for me? I realize it won't be perfect because of some types of names and titles etc, but i can deal with the occasional mis-capitalized name.

  2. #2
    Valued Forum Contributor MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    5,318

    Re: Change Case of recipients name when sending email

    Hi marcusjb,

    I don't find a Proper Case function in Outlook but do find a routine that may help at
    http://www.utteraccess.com/forum/Con....html&p=781258
    One test is worth a thousand opinions.
    Click the * below to say thanks.

  3. #3
    Registered User
    Join Date
    02-10-2005
    Posts
    5

    Re: Change Case of recipients name when sending email

    Seems complicated. I'm not really sure what to do with functions.

  4. #4
    Forum Guru
    Join Date
    06-18-2004
    Location
    Canada
    Posts
    1,330

    Re: Change Case of recipients name when sending email

    Assuming that when an email is created it remains displayed in a window, try...

    Option Explicit
    
    Sub test()
    
        Dim objOutlook As Outlook.Application
        Dim objInspector As Outlook.Inspector
        Dim objMailItem As Outlook.MailItem
        Dim i As Integer
        Dim v As Variant
        Dim x As Variant
        Dim y As String
        Dim strRecipients As String
        
        Set objOutlook = GetObject(, "Outlook.Application")
        
        For Each objInspector In Outlook.Inspectors
            Set objMailItem = objInspector.CurrentItem
            With objMailItem
                If .To <> "" Then
                    v = Split(.To & ";", ";")
                    For i = LBound(v) To UBound(v)
                        If v(i) <> "" Then
                            If InStr(1, v(i), "(") > 0 Then
                                x = Split(v(i), "(")
                                y = WorksheetFunction.Proper(LTrim(x(0))) & "(" & x(1)
                                strRecipients = strRecipients & y & "; "
                            Else
                                strRecipients = strRecipients & LTrim(v(i)) & "; "
                            End If
                        End If
                    Next i
                    .To = strRecipients
                    strRecipients = ""
                End If
            End With
        Next objInspector
        
    End Sub
    
    It should deal with one or more recipients, and in varying formats, such as the following...

    JOHN SMITH (johnsmith@xyz.com) =====> John Smith (johnsmith@xyz.com)

    JOHN SMITH (johnsmith@xyz.com); jane doe; joe@abc.com; JOE BLACK (joeblack@xyz.com) =====> John Smith (johnsmith@xyz.com); jane doe; joe@abc.com; Joe Black (joeblack@xyz.com)
    Domenic
    Microsoft MVP - Excel
    xl-central.com, "Your Quick Reference to Excel Solutions"

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0