Share via


How to: Manage the Add-In

 

Applies To: Windows Server 2012 Essentials

In addition to managing the hosted email service, you can also manage the add-in itself. Add-in management mainly consists of enabling or disabling the add-in. When you add your custom integration features to the UI, you can access this functionality through the HostedEmailIntegrationManager object. In addition, you can also gain information about the add-in through the Configuration property. This property (itself a HostedEmailConfiguration object) contains a number of pieces of information retrieved from the add-in XML configuration file.

However, one of the more commonly-used properties is Service. While the other properties describe the add-in assembly itself, this property describes the hosted email service itself. As such, Service is the primary means of accessing information about the service.

The following code samples describe how to use the HostedEmailIntegrationManager, and the associated HostedEmailConfiguration and Service objects, to access information about the add-in and service. For the complete code samples, see Quickstart: Creating a Hosted Email Adapter.

Example

The following code shows how to use the HostedEmailIntegrationManager to determine if the hosted email service is completely installed. The code checks both if the add-in has been enabled, and if the integration manager is enabled as well. The method is a helper function used as part of the Dashboard UI modifications.

private static bool ContosoEmailEnabled  
{  
    get  
    {  
        return (HostedEmailIntegrationManager.IsEnabled() && HostedEmailIntegrationManager.EnabledAddinId.Equals(Constants.AdaptorId));  
    }  
}  
  

Example

The following code retrieves the URL of the user portal from the HostedEmailConfiguration.Service property, as part of creating an object to retrieve account information from the hosted email service.

private static AsyncUiTask CreateVisitMyAccountTask()  
{  
    AsyncUiTask task = new AsyncUiTask(  
        UIConstants.VisitMyAccountTask,  
        Resources.ContosoServicesVisitMyAccountTask_DisplayName,  
        delegate(object obj)  
        {  
            Uri userPortal = null;   
            if (ContosoEmailEnabled)  
            {  
                userPortal = HostedEmailIntegrationManager.Configuration.Service.ServiceUserPortal;  
            }                   
            if(userPortal == null)  
            {  
  
                userPortal = new Uri(Resources.ContosoServices_DefaultUserPortal);  
            }  
            System.Diagnostics.Process.Start(userPortal.ToString());  
  
            return null;  
        },  
        true //global task  
    );  
    return task;  
}  
  

Example

The following code sample is a custom action that checks to see if the adapter has been disabled before beginning uninstallation.

public static ActionResult UninstallCheck(Session session)  
{  
    session.Log("Begin UninstallCheck");  
    try  
    {  
  
        if (HostedEmailIntegrationManager.EnabledAddinId.Equals(new Guid(addinId)))  
        {  
            session.Log("Current hosted email addin is enabled, prevent it being uninstalled");  
            return ActionResult.Failure;  
        }  
    }  
    catch (Exception e)  
    {  
        session.Log("UninstallCheck failed due to {0}", e.Message);  
        return ActionResult.Failure;  
    }  
    return ActionResult.Success;  
}