none
Need help on my edit outlook contacts script RRS feed

  • Question

  • Hello my friends

    I'm here posting on this forum to ask for your help.

    Simple as this

    Code:

    For Each item in oContactFolder.Items
        If InStr(1, item.Email1Address, abruno, vbTextCompare) > 0 Then _
            item.Email1Address = Replace(item.Email1Address, abruno, nbruno, 1, 1, vbTextCompare)
        item.Save
    Next

    And in some computeres work and on other don't. Displays this error:

    On computers with the same version of office, and don't work, others work, and with different versions

    - object doesn't support this property or method: item.Email1Address

    Can someome explain it to me or help me fix it?


    Monday, May 30, 2016 9:53 PM

Answers

  • Contacts do not all have email addresses.

    It would be more reliable to do it like this:

    For Each item in oContactFolder.Items
    if item.Class = 40 Then
    If InStr(item.Email1Address, abruno) Then
    item.Email1Address = Replace(item.Email1Address, abruno)
    item.Save
    End If
    End If
    Next


    \_(ツ)_/




    • Edited by jrv Monday, May 30, 2016 10:32 PM
    • Marked as answer by dnTTT Tuesday, May 31, 2016 1:13 PM
    Monday, May 30, 2016 10:25 PM

All replies

  • Contacts do not all have email addresses.

    It would be more reliable to do it like this:

    For Each item in oContactFolder.Items
    if item.Class = 40 Then
    If InStr(item.Email1Address, abruno) Then
    item.Email1Address = Replace(item.Email1Address, abruno)
    item.Save
    End If
    End If
    Next


    \_(ツ)_/




    • Edited by jrv Monday, May 30, 2016 10:32 PM
    • Marked as answer by dnTTT Tuesday, May 31, 2016 1:13 PM
    Monday, May 30, 2016 10:25 PM
  • Note also that you must check for class or other item types without an "email1address" will throw errors.


    \_(ツ)_/

    Monday, May 30, 2016 10:38 PM
  • Contacts do not all have email addresses.

    It would be more reliable to do it like this:

    For Each item in oContactFolder.Items
    if item.Class = 40 Then
    If InStr(item.Email1Address, abruno) Then
    item.Email1Address = Replace(item.Email1Address, abruno)
    item.Save
    End If
    End If
    Next


    \_(ツ)_/




    Thank you so much, it works!

    I don't have words to thank you! you spare me a lot of boring work, thanks a lot!

    I only edit this

    item.Email1Address = Replace(item.Email1Address, abruno)

    to:

    item.Email1Address = Replace(item.Email1Address, abruno, nbruno)

    abruno = old email

    nbruno = new email

    Tuesday, May 31, 2016 1:13 PM