Office365中的电子邮件签名

时间:2015-09-22 09:23:30

标签: exchange-server office365

我想构建一个电子邮件签名应用程序。因为这些是主要功能

a)显示电子邮件签名模板列表

b)客户将选择任何一个模板并修改文本

c)客户将点击确认按钮

将该签名添加到他们的office365帐户

我的要求是,我想知道如何通过C#代码中的API为office365帐户生成电子邮件签名?

1 个答案:

答案 0 :(得分:0)

Collection<PSObject> psresult;

using (Runspace myRunSpace = RunspaceFactory.CreateRunspace())
{
    myRunSpace.Open();
    PowerShell powershell = PowerShell.Create();
    powershell.Runspace = myRunSpace;

    using (powershell)
    {
        powershell.AddScript("$Username = 'username'; $Password = ConvertTo-SecureString 'password' -AsPlainText -Force; $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password; $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri 'https://outlook.office365.com/powershell-liveid/' -Credential $cred -Authentication Basic -AllowRedirection; Import-PSSession $Session; Set-Mailboxmessageconfiguration -identity 'user' -signaturehtml 'SignatureInHTML' -autoaddsignature $true ; Remove-PSSession $session");
        psresult = powershell.Invoke();
    }
    powershell = null;
    myRunSpace.Close();
}