【问题标题】:iPhone Activesync for Outlook contact "other" phone numbers not syncingiPhone Activesync for Outlook 联系人“其他”电话号码未同步
【发布时间】:2020-01-24 16:15:15
【问题描述】:

我找到了一个我正在尝试运行但有问题的修复程序。当我在 Powershell 中输入第二行时,出现以下错误。我有许多通过 sf.com 在 Outlook 中同步的联系人记录,不确定是否是问题所在。如果您能帮我修复命令,那么我可以将这些记录从“其他”更改为 iphone(Activesynce) 将同步的电话字段,例如移动电话或寻呼机。我不希望它取代当前的手机号码,只是对其进行分类。谢谢!

$outlook = new-object -com outlook.application
$contacts = $outlook.Session.GetDefaultFolder(10)
$contacts.Items | % { if($_.MobileTelephoneNumber -eq "") { $_.MobileTelephoneNumber = $_.OtherTelephoneNumber; $_.OtherTelephoneNumber = ""; $_.save() } }

错误

您不能在空值表达式上调用方法。在行:1 字符:1 + $OutlookContacts = $Outlook.session.GetDefaultFolder(10).items + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull

【问题讨论】:

    标签: powershell office365 outlook-2016


    【解决方案1】:

    恐怖是非常具体的。

    Null 表示 Null。 / 它没有任何用处。

    不要猜测(好吧,有时我们都会这样做...... ;-} - 但不要让它成为习惯。),因为你只会不必要地让自己感到沮丧,因此会导致很多不必要的头发拉扯,我没有头发了,所以,你知道我的意思。

    始终按步骤开发您的代码,以确保您得到预期的结果。因此,在活动行/块有效之前无需进行下一步。

    示例(使用变量挤压来分配结果并输出到屏幕)

    ($outlook = new-object -com outlook.application)
    
    # Results
    <#
    Application        : Microsoft.Office.Interop.Outlook.ApplicationClass
    Class              : olApplication
    Session            : Microsoft.Office.Interop.Outlook.NameSpaceClass
    Parent             : 
    Assistant          : 
    Name               : Outlook
    Version            : 16.0.0.12325
    ...
    PickerDialog       : System.__ComObject
    #>
    
    
    ($contacts = $outlook.Session.GetDefaultFolder(10))
    
    # Results
    <#
    Application            : Microsoft.Office.Interop.Outlook.ApplicationClass
    Class                  : 2
    Session                : Microsoft.Office.Interop.Outlook.NameSpaceClass
    Parent                 : System.__ComObject
    DefaultItemType        : 2
    DefaultMessageClass    : IPM.Contact
    ...
    #>
    
    $contacts.Items
    
    # Results
    <#
    Application                  : Microsoft.Office.Interop.Outlook.ApplicationClass
    Class                        : 40
    Session                      : System.__ComObject
    Parent                       : System.__ComObject
    Actions                      : System.__ComObject
    Attachments                  : System.__ComObject
    BillingInformation           : 
    Body                         : 
    Categories                   : 
    ...
    #>
    
    $contacts.Items | 
    % { 
        if($_.MobileTelephoneNumber -eq '') 
        {
            "MobileTelephoneNumber: $($PSItem.MobileTelephoneNumber)"
            "OtherTelephoneNumber: $($PSItem.OtherTelephoneNumber)"
            <#
            $_.MobileTelephoneNumber = $_.OtherTelephoneNumber 
            $_.OtherTelephoneNumber = '' 
            $_.save() 
            #>
        } 
    } | Select-Object -First 20
    
    # Results
    <#
    MobileTelephoneNumber: 
    OtherTelephoneNumber: 
    ...
    MobileTelephoneNumber: 
    OtherTelephoneNumber: (800) 555-1212 ,,,4472
    ...
    #>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-12
      • 1970-01-01
      • 2014-12-30
      • 2014-04-22
      • 2012-04-26
      • 2015-01-24
      • 2018-01-08
      相关资源
      最近更新 更多