Outlook 2016签名和活动目录

时间:2016-03-23 22:04:25

标签: active-directory office-2016 outlook-2016

我有这个脚本创建一个outlook签名并查看Active Directory的日期(DisplayName,Telephone和Title)。

我有这行代码将.docx文件复制到appdata并将其保存在html,rtf和txt中。

#Save new message signature 
Write-Output "Saving signatures"
#Save HTML
$saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatHTML");
$path = $LocalSignaturePath+'\'+$SignatureName+".htm"
$MSWord.ActiveDocument.saveas([ref]$path, [ref]$saveFormat)

#Save RTF 
$saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatRTF");
$path = $LocalSignaturePath+'\'+$SignatureName+".rtf"
$MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$saveFormat)

#Save TXT    
$saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatText");
$path = $LocalSignaturePath+'\'+$SignatureName+".txt"
$MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$SaveFormat)
$MSWord.ActiveDocument.Close()
$MSWord.Quit()

它适用于Outlook 2013.但是当我为Outlook 2016运行它时,我收到以下错误

Unable to find type [Microsoft.Office.Interop.Word.WdSaveFormat].
At C:\Users\rob\Downloads\set_outlook_signature\set_outlook_signature.ps1:142 char:1
+ $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveForm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Offic...rd.WdSaveFormat:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

[ref] cannot be applied to a variable that does not exist.
At C:\Users\rob\Downloads\set_outlook_signature\set_outlook_signature.ps1:144 char:1
+ $MSWord.ActiveDocument.saveas([ref]$path, [ref]$saveFormat)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (saveFormat:VariablePath) [], RuntimeException
    + FullyQualifiedErrorId : NonExistingVariableReference

Unable to find type [Microsoft.Office.Interop.Word.WdSaveFormat].
At C:\Users\rob\Downloads\set_outlook_signature\set_outlook_signature.ps1:147 char:1
+ $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveForm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Offic...rd.WdSaveFormat:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

[ref] cannot be applied to a variable that does not exist.
At C:\Users\rob\Downloads\set_outlook_signature\set_outlook_signature.ps1:149 char:1
+ $MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$saveFormat)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (saveFormat:VariablePath) [], RuntimeException
    + FullyQualifiedErrorId : NonExistingVariableReference

Unable to find type [Microsoft.Office.Interop.Word.WdSaveFormat].
At C:\Users\rob\Downloads\set_outlook_signature\set_outlook_signature.ps1:152 char:1
+ $saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveForm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Offic...rd.WdSaveFormat:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

[ref] cannot be applied to a variable that does not exist.
At C:\Users\rob\Downloads\set_outlook_signature\set_outlook_signature.ps1:154 char:1
+ $MSWord.ActiveDocument.SaveAs([ref] $path, [ref]$SaveFormat)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (SaveFormat:VariablePath) [], RuntimeException
    + FullyQualifiedErrorId : NonExistingVariableReference

Outlook 2016是否有不同的格式。想法?

谢谢!

1 个答案:

答案 0 :(得分:0)

如果您安装了32位Office,请尝试以32位PowerShell运行该脚本。

我创建了一个.bat文件,执行以下+脚本

%SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe c:\myscript.ps1