Create a Mailbox in Outlook Live

In order to use this code you have to grab the Class Sessions from this link and read the introduction

CODE

I am returning a String to grab the Exception, if created return “1”. This work’s but for instance if a mailbox with the same name is already created it will not give any exception, at least for me.

Using  Microsoft.LiveAtEdu.Samples.Powershell.OutlookLive.Users.MailBox;

/// <summary>
/// Cria Caixa de Correio.
/// </summary>
/// <param name="primeiroNome">Nova Caixa Correio Primeiro Nome</param>
/// <param name="ultimoNome">Nova Caixa Correio ultimo nome.</param>
/// <param name="nomeParaDisplay">Nome display</param>
/// <param name="caixaCorreio">O Email a criar</param>
/// <param name="password"></param>
public static string CreateMailBox(string firstName, 
                                   string lastName, 
                                   string displayName, 
                                   string mailBox, 
                                   string password)
{
    try
    {
        OutlookLiveMailBox mb = new OutlookLiveMailBox(Sessions.ConnectMe());
        mb.CreateMailBox(firstName, lastName, displayName, mailBox, password);
        return "1";
    }
    catch (Exception ex)
    {
        return ex.Message;
    }
    finally
    {
        Sessions.DisconnectMe();
    }
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s