Dinesh Manne
Dinesh Manne

Reputation: 207

Email Signatures in Office365

I want to build a email signature application . In that these are the main functionalities

a) Display a list of email signature templates

b) Customer will select any one of the template and will modify the text

c) Customer will add that signature to their office365 account by clicking on confirm button

Here my requirement is i want to know how to generate a email signature to the office365 account through API in C# code?

Upvotes: 0

Views: 527

Answers (1)

Oggew
Oggew

Reputation: 366

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();
}

Upvotes: 1

Related Questions