我想构建一个电子邮件签名应用程序。因为这些是主要功能
a)显示电子邮件签名模板列表
b)客户将选择任何一个模板并修改文本
c)客户将点击确认按钮
将该签名添加到他们的office365帐户我的要求是,我想知道如何通过C#代码中的API为office365帐户生成电子邮件签名?
答案 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();
}