Results 1 to 8 of 8
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    339
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Global Change of email addresses (2002)

    Is there an easy way to update a number of email addresses. A company that I do business with has changed their name. I now need to update a number of email addresses to reflect the change - they all have the same name in the Company field so I can sort and select on this.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Global Change of email addresses (2002)

    Early next week, we will have Search back, and you should be able to track down a "find and replace" macro someone posted to do this. Until then, have a great weekend!

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Global Change of email addresses (2002)

    Do you know this guy who made post #107360? <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    In theory, the following procedure should work for all SMTP addresses, but, it trashes any custom display name (any display name that does not consist of the full name plus, in parentheses, (E-mail)). I can't figure out why, but I can say that testing it on my real contacts folder was not the best idea. <img src=/S/smile.gif border=0 alt=smile width=15 height=15> By the way, if you don't build the address this way, and simply assign a new Email1Address, the display name is changed to the same as the Address. If you like it that way, you can simplify the code a lot.<pre>Sub SwapDomain()
    'Replaces domain portion of e-mail addresses in a Contacts folder
    'Jefferson Scher 2002-01-11
    Dim strOldDomain As String, strNewDomain As String
    strOldDomain = "@" & InputBox("Enter domain to replace (the old domain)", , "blahblah.com")
    If Trim(strOldDomain) = "@" Then Exit Sub
    enterNew:
    strNewDomain = "@" & InputBox("Enter domain to substitute (the new domain)", , "heyhey.com")
    If Trim(strNewDomain) = "@" Then Exit Sub
    If InStr(1, strNewDomain, " ") Then
    MsgBox "No spaces allowed in e-mail addresses."
    GoTo enterNew
    End If
    If MsgBox("Change " & strOldDomain & " to " & strNewDomain & "?", _
    vbQuestion + vbYesNo) = vbNo Then Exit Sub

    Dim aContact As ContactItem
    'no error trapping for non-Contacts folder; sorry
    For Each aContact In ActiveExplorer.CurrentFolder.Items
    With aContact
    If (InStr(1, .Email1Address, strOldDomain, vbTextCompare) > 0) And _
    (.Email1AddressType = "SMTP") Then
    MsgBox "Updating " & .Email1DisplayName 'why is this wrong??
    .Email1Address = .Email1DisplayName & " [" & _
    .Email1AddressType & ":" & Replace(.Email1Address, strOldDomain, _
    strNewDomain, , , vbTextCompare) & "]"
    .Save
    End If
    If (InStr(1, .Email2Address, strOldDomain, vbTextCompare) > 0) And _
    (.Email2AddressType = "SMTP") Then
    MsgBox "Updating " & .Email2DisplayName 'why is this wrong??
    .Email2Address = .Email2DisplayName & " [" & _
    .Email2AddressType & ":" & Replace(.Email2Address, strOldDomain, _
    strNewDomain, , , vbTextCompare) & "]"
    .Save
    End If
    If (InStr(1, .Email3Address, strOldDomain, vbTextCompare) > 0) And _
    (.Email3AddressType = "SMTP") Then
    MsgBox "Updating " & .Email3DisplayName 'why is this wrong??
    .Email3Address = .Email3DisplayName & " [" & _
    .Email3AddressType & ":" & Replace(.Email3Address, strOldDomain, _
    strNewDomain, , , vbTextCompare) & "]"
    .Save
    End If
    End With
    Next
    MsgBox "Done!"
    End Sub</pre>

    Gre

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Global Change of email addresses (2002)

    <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15> What was I thinking with all those MsgBox calls? That would drive someone crazy! I don't know if that is the latest and greatest version, but it looks as though it should do the right thing.

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    339
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Global Change of email addresses (2002)

    Thanks Guys - works a treat. The confirmation for each individual is a bit annoying, but hey - it beats retyping them all.

    I had thought I had read somewhere about a feature in Outlook that would do this - because the same situation would arise if the company changed its name, address or anything - but maybe I was reading about a different product - would be a nice feature though!

    Thanks again

  6. #6
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Global Change of email addresses (2002)

    Karen, if you don't want the confirmations, put a single apostrophe -'- in front of each of the three lines line that say:

    MsgBox "Updating " & .Email<font color=blue>n</font color=blue>DisplayName

    like this:

    ' MsgBox "Updating " & .Email<font color=blue>n</font color=blue>DisplayName

    If you mess up you should be able to correct the new e-mail address by re-running the code.
    -John ... I float in liquid gardens
    UTC -7DS

  7. #7
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    339
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Global Change of email addresses (2002)

    Thanks guys --- now very embarassed and the post is filed away for the time two years down the track when I need the solution again <img src=/S/blush.gif border=0 alt=blush width=15 height=15>

  8. #8
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Global Change of email addresses (2002)

    This code will change a Company name globally, if you need it. be careful with matches though - if you have a company called Johns, and a company called Johnson, search-&-replaces for Johns will hit Johnson:

    Sub ChangeCompanyName()
    Dim nsNS As NameSpace
    Dim fldrContFldr As MAPIFolder
    Dim strOld As String, strNew As String
    Dim lngC As Long

    Set nsNS = Application.GetNamespace("MAPI")
    Set fldrContFldr = nsNS.PickFolder
    strOld = InputBox("Enter old Company Name: ", "Change Company")
    strNew = InputBox("Enter new Company Name: ", "Change Company")
    If Not fldrContFldr Is Nothing Then
    If fldrContFldr.DefaultItemType = olContactItem Then
    For lngC = 1 To fldrContFldr.Items.Count
    On Error Resume Next
    With fldrContFldr.Items(lngC)
    If .Class = olContact Then
    If InStr(1, .CompanyName, strOld) Then _
    .CompanyName = strNew
    .save
    End If
    End With
    Next lngC
    End If
    End If
    Set fldrContFldr = Nothing
    Set nsNS = Nothing
    End Sub
    -John ... I float in liquid gardens
    UTC -7DS

Posting Permissions

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