IAdmExportExchangeMailboxOps

The IAdmExportExchangeMailboxOps interface provides methods for exporting Exchange mailboxes.

Inheritance: IDispatch

To export mailboxes, the account Adaxes uses to manage the AD domain where the mailbox is located must be assigned to the Mailbox Import Export role in Exchange.

Methods

Details

CreateMailboxExportRequest()

Creates a request for exporting a user's Exchange mailbox to a Personal Storage Table (PST) file.

string CreateMailboxExportRequest(string filePath, 
                                  int badItemLimit, 
                                  int largeItemLimit)

Parameters

  • filePath - Specifies the full UNC path to the PST file that will contain the mailbox data (e.g. \\SERVER\Backups\JSmith.pst).
  • badItemLimit - Specifies the maximum number of bad items that are allowed before the request fails. A bad item is a corrupt item in the mailbox that can't be exported to the PST file. Use 0 to not skip bad items. The valid input range for this parameter is from 0 through 2147483647.
  • largeItemLimit - Specifies the number of large items to skip if the request encounters such items in the mailbox. A large item is a message in the mailbox that exceeds the maximum allowed message size. Use 0 to not skip any large items.

Return value

The method returns a request ID that can be used to track the mailbox export progress.

Examples

The following code sample initiates mailbox export and outputs the status of the operation after 30 seconds.

PowerShell
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"
$filePath = "\\SERVER\Backups\JSmith.pst"

# Connect to the Adaxes service
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")

# Bind to the user
$user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0)

# Export the mailbox
$requestId = $user.CreateMailboxExportRequest($filePath, 0, 0)

# Wait 30 seconds
Start-Sleep -Seconds 30

# Get mailbox export request info
$requestInfo = $user.GetMailboxExportRequestInfo($requestId, $false)

# Status
Write-Host "Status: " -NoNewline
switch ($requestInfo.Status)
{
    "ADM_EXPORTMAILBOXSTATUS_NONE"
    {
        Write-Host "There are no export requests for the mailbox."
    }
    "ADM_EXPORTMAILBOXSTATUS_INPROCESS"
    {
        Write-Host "The mailbox is being exported."
    }
    "ADM_EXPORTMAILBOXSTATUS_SUCCEEDED"
    {
        Write-Host "The mailbox has been exported successfully."
    }
    "ADM_EXPORTMAILBOXSTATUS_FAILED"
    {
        Write-Host $requestInfo.FailureMessage
    }
}
C#
using System;
using System.Threading;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi.Exchange;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;

class Program
{
    static void Main(string[] args)
    {
        const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com";
        const string filePath = @"\\SERVER\Backups\JSmith.pst";

        // Connect to the Adaxes service
        AdmNamespace ns = new AdmNamespace();
        IAdmService service = ns.GetServiceDirectly("localhost");

        // Bind to the user
        IAdmExportExchangeMailboxOps user = (IAdmExportExchangeMailboxOps)service.OpenObject(
            userPath, null, null, 0);

        // Export the mailbox
        string requestId = user.CreateMailboxExportRequest(filePath, 0, 0);

        // Wait 30 seconds
        Thread.Sleep(30000);

        // Get mailbox export request info
        IAdmExportExchangeMailboxRequestInfo requestInfo =
            user.GetMailboxExportRequestInfo(requestId, false);

        // Status
        Console.Write("Status: ");
        switch (requestInfo.Status)
        {
            case ADM_EXPORTMAILBOXSTATUS_ENUM.ADM_EXPORTMAILBOXSTATUS_NONE:
                Console.WriteLine("There are no export requests for the mailbox.");
                break;
            case ADM_EXPORTMAILBOXSTATUS_ENUM.ADM_EXPORTMAILBOXSTATUS_INPROCESS:
                Console.WriteLine("The mailbox is being exported.");
                break;
            case ADM_EXPORTMAILBOXSTATUS_ENUM.ADM_EXPORTMAILBOXSTATUS_SUCCEEDED:
                Console.WriteLine("The mailbox has been exported successfully.");
                break;
            case ADM_EXPORTMAILBOXSTATUS_ENUM.ADM_EXPORTMAILBOXSTATUS_FAILED:
                Console.WriteLine(requestInfo.FailureMessage);
                break;
        }
    }
}

GetMailboxExportRequestInfo()

Gets information about a mailbox export request.

IAdmExportExchangeMailboxRequestInfo GetMailboxExportRequestInfo(string requestId, 
                                                                 bool includeReport)

Parameters

  • requestId - Specifies the ID of the mailbox export request to get information about.
  • includeReport - Specifies whether to return additional details, which can be used for troubleshooting.

Examples

The following code sample initiates mailbox export and outputs the status of the operation after 30 seconds.

PowerShell
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"
$filePath = "\\SERVER\Backups\JSmith.pst"

# Connect to the the Adaxes service
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")

# Bind to the user
$user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0)

# Export the mailbox
$requestId = $user.CreateMailboxExportRequest($filePath, 0, 0)

# Wait 30 seconds
Start-Sleep -Seconds 30

# Get mailbox export request info
$requestInfo = $user.GetMailboxExportRequestInfo($requestId, $true)

# Status
Write-Host "Status: " -NoNewline
switch ($requestInfo.Status)
{
    "ADM_EXPORTMAILBOXSTATUS_NONE"
    {
        Write-Host "There are no export requests for the mailbox."
    }
    "ADM_EXPORTMAILBOXSTATUS_SUCCEEDED"
    {
        Write-Host "The mailbox has been exported successfully."
    }
    "ADM_EXPORTMAILBOXSTATUS_FAILED"
    {
        Write-Host $requestInfo.FailureMessage
    }
    "ADM_EXPORTMAILBOXSTATUS_INPROCESS"
    {
        Write-Host "Items exported:" $requestInfo.ItemsTransferred
        Write-Host "Bytes exported:" $requestInfo.BytesTransferred
        Write-Host "Speed:" $requestInfo.BytesTransferredPerMinute "bytes per minute"
        Write-Host "Progress:" $requestInfo.PercentComplete "%"
    }
}
C#
using System;
using System.Threading;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi.Exchange;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;

class Program
{
    static void Main(string[] args)
    {
        const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com";
        const string filePath = @"\\SERVER\Backups\JSmith.pst";

        // Connect to the the Adaxes service
        AdmNamespace ns = new AdmNamespace();
        IAdmService service = ns.GetServiceDirectly("localhost");

        // Bind to the user
        IAdmExportExchangeMailboxOps user = (IAdmExportExchangeMailboxOps)service.OpenObject(
            userPath, null, null, 0);

        // Export the mailbox
        string requestId = user.CreateMailboxExportRequest(filePath, 0, 0);

        // Wait 30 seconds
        Thread.Sleep(30000);

        // Get mailbox export request info
        IAdmExportExchangeMailboxRequestInfo requestInfo =
            user.GetMailboxExportRequestInfo(requestId, true);

        // Status
        Console.Write("Status: ");
        switch (requestInfo.Status)
        {
            case ADM_EXPORTMAILBOXSTATUS_ENUM.ADM_EXPORTMAILBOXSTATUS_NONE:
                Console.WriteLine("There are no export requests for the mailbox.");
                break;
            case ADM_EXPORTMAILBOXSTATUS_ENUM.ADM_EXPORTMAILBOXSTATUS_SUCCEEDED:
                Console.WriteLine("The mailbox has been exported successfully.");
                break;
            case ADM_EXPORTMAILBOXSTATUS_ENUM.ADM_EXPORTMAILBOXSTATUS_FAILED:
                Console.WriteLine(requestInfo.FailureMessage);
                break;
            case ADM_EXPORTMAILBOXSTATUS_ENUM.ADM_EXPORTMAILBOXSTATUS_INPROCESS:
                Console.WriteLine("Items exported: " + requestInfo.ItemsTransferred);
                Console.WriteLine("Bytes exported: " + requestInfo.BytesTransferred);
                Console.WriteLine("Speed: " + requestInfo.BytesTransferredPerMinute);
                Console.WriteLine("Progress: " + requestInfo.PercentComplete + "%");
                break;
        }
    }
}

CancelMailboxExportRequest()

Cancels an ongoing mailbox export request.

void CancelMailboxExportRequest(string requestId)

Parameters

The requestId parameter specifies the identifier of the mailbox export request to cancel.

Examples

The following code sample initiates mailbox export and then cancels it.

PowerShell
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"
$filePath = "\\SERVER\Backups\JSmith.pst"

# Connect to the Adaxes service
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")

# Bind to the user
$user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0)

# Export the mailbox
$requestId = $user.CreateMailboxExportRequest($filePath, 0, 0)

# Cancel mailbox export request
$user.CancelMailboxExportRequest($requestId)
C#
using System;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi.Exchange;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;

class Program
{
    static void Main(string[] args)
    {
        const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com";
        const string filePath = @"\\SERVER\Backups\JSmith.pst";

        // Connect to the Adaxes service
        AdmNamespace ns = new AdmNamespace();
        IAdmService service = ns.GetServiceDirectly("localhost");

        // Bind to the user
        IAdmExportExchangeMailboxOps user = (IAdmExportExchangeMailboxOps)service.OpenObject(
            userPath, null, null, 0);

        // Export the mailbox
        string requestId = user.CreateMailboxExportRequest(filePath, 0, 0);

        // Cancel mailbox export request
        user.CancelMailboxExportRequest(requestId);
    }
}

DeleteMailboxExportRequest()

Deletes a mailbox export request.

void DeleteMailboxExportRequest(string requestId)

Parameters

The requestId parameter specifies the identifier of the mailbox export request to delete.

Examples

The following code sample initiates mailbox export and deletes the associated mailbox export request when the export is completed.

PowerShell
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$userDN = "CN=John Smith,CN=Users,DC=domain,DC=com"
$filePath = "\\SERVER\Backups\JSmith.pst"

# Connect to the Adaxes service
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")

# Bind to the user
$user = $service.OpenObject("Adaxes://$userDN", $null, $null, 0)

# Export the mailbox
$requestId = $user.CreateMailboxExportRequest($filePath, 0, 0)

# Get mailbox export request info
$requestInfo = $user.GetMailboxExportRequestInfo($requestId, $false)

while ($requestInfo.Status -eq "ADM_EXPORTMAILBOXSTATUS_INPROCESS")
{
    Start-Sleep -Seconds 20
    $requestInfo = $user.GetMailboxExportRequestInfo($requestId, $false)
}

# Status
Write-Host "Status: " -NoNewline
switch ($requestInfo.Status)
{
    "ADM_EXPORTMAILBOXSTATUS_SUCCEEDED"
    {
        Write-Host "The mailbox has been exported successfully."
    }
    "ADM_EXPORTMAILBOXSTATUS_FAILED"
    {
        Write-Host $requestInfo.FailureMessage
    }
}

# Delete mailbox export request
$user.DeleteMailboxExportRequest($requestId)
C#
using System;
using System.Threading;
using Softerra.Adaxes.Adsi;
using Softerra.Adaxes.Interop.Adsi.Exchange;
using Softerra.Adaxes.Interop.Adsi.PersistentObjects;

class Program
{
    static void Main(string[] args)
    {
        const string userPath = "Adaxes://CN=John Smith,CN=Users,DC=domain,DC=com";
        const string filePath = @"\\SERVER\Backups\JSmith.pst";

        // Connect to the Adaxes service
        AdmNamespace ns = new AdmNamespace();
        IAdmService service = ns.GetServiceDirectly("localhost");

        // Bind to the user
        IAdmExportExchangeMailboxOps user = (IAdmExportExchangeMailboxOps)service.OpenObject(
            userPath, null, null, 0);

        // Export the mailbox
        string requestId = user.CreateMailboxExportRequest(filePath, 0, 0);

        // Get mailbox export request info
        IAdmExportExchangeMailboxRequestInfo requestInfo =
            user.GetMailboxExportRequestInfo(requestId, false);

        while (requestInfo.Status == ADM_EXPORTMAILBOXSTATUS_ENUM.ADM_EXPORTMAILBOXSTATUS_INPROCESS)
        {
            Thread.Sleep(30000);
            requestInfo = user.GetMailboxExportRequestInfo(requestId, false);
        }

        // Status
        Console.Write("Status: ");
        switch (requestInfo.Status)
        {
            case ADM_EXPORTMAILBOXSTATUS_ENUM.ADM_EXPORTMAILBOXSTATUS_SUCCEEDED:
                Console.WriteLine("The mailbox has been exported successfully.");
                break;
            case ADM_EXPORTMAILBOXSTATUS_ENUM.ADM_EXPORTMAILBOXSTATUS_FAILED:
                Console.WriteLine(requestInfo.FailureMessage);
                break;
        }

        // Delete mailbox export request
        user.DeleteMailboxExportRequest(requestId);
    }
}

Requirements

Minimum required version: 2015

See also