Home > Development, SharePoint Server 2010 > How to display IBM Lotus Domino mails inbox in SharePoint server 2010

How to display IBM Lotus Domino mails inbox in SharePoint server 2010

Case Study: How to display IBM Lotus Domino mails inbox in SharePoint server 2010

Here we will display how SharePoint Server 2010 can integrate with lotus domino server by discussing this case study.

In our case study we want to retrieve lotus domino mails inbox for each user and display this content inside custom web part in SharePoint server2010.

Our farm servers as the following

Server Name Role
Domino-Lab Hosts Domino Server
SharePoint-Lab Hosts SharePoint Server 2010

Since Domino V 2.0.2, the back-end domino objects have a COM interface with the following interface

  • COM requires the presence of Domino or Notes; the software can be Domino server, Domino Designer, or Notes client.
  •  COM provides both early-binding (custom) and late-binding (dispatch) interfaces. Early binding makes the Domino classes available as typed variables with compile-time checking. Late binding can be used where the language (for example, VBScript) precludes early binding.
  • The COM interface is the same as the Lotus Script interface, with some exceptions.
  •  Domino can act as a COM server or a COM Client.

Microsoft .NET can access Domino Objects through COM. To accomplish this,.NET client or .NET Web Services can call Domino objects via a special wrapper. This wrapper; known as Runtime-Callable Wrapper (RCW), is a piece of software that can accept commands from a component, modify them and forward them to another component. Microsoft .NET Common Language Runtime (CLR) uses the RCW to operate with the unmanaged code by making COM calls to the Domino objects as depicted in the following figure.

In the same way, Lotus Domino can act as COM client and provide .NET objects via a special wrapper known as a COM Callable Wrapper (CCW). The Domino COM Client uses the CCW to operate with Microsoft .NET Common Language Runtime (CLR) by making .NET calls to .NET servers, as depicted in the following figure.

Our example shows how to create .Net web service hosted on Domino-Lab Server and consume it in a custom web part will be hosted on SharePoint-Lab Server.

Let us go through the details of creating each of the web service which retrieves the content of Lotus Domino mail inbox and the web part which will consumes the web service.

ON Domino-Lab Server:-

 

The following software to be installed for developing custom web service:-

1-     Lotus Domino Server V 8.5.

2-     IIS 5 or higher.

3-     Microsoft IE v5.5 or newer.

4-     Visual Studio 2005 or newer.

 

Once you have installed the above products, do the following steps:-

1-     Make the domino objects accessible to .NET and IIS.

2-     Create .NET web service to access mail database for retrieving mails.

3-     Test the example.

Making the domino objects accessible to .NET and IIS

 

Because the Domino Objects are not included as standard within the .NET Framework Software Developer Kit (SDK), there is a tool included in the software called Tlbimp (type library imported) that reads the Domino COM Type Library (domobj.tlb) and creates a matching CLR assembly (domobj.dll) which will be in

Charge of calling the COM Components.

The Tlbimp tool is a command-line tool which will make the job of RCW easier because it is capable of converting COM metadata to .NET metadata.

To create domobj.DLL from the command prompt:-

a-      Go to Visual Studio command prompt , the navigate to the directory of domino and type as the following :-

tlbimp domobj.tlb /out:domobj.dll


 

Creating a .NET Web Service to access the Domino database

1-     Open visual studio, select create new web site, from dialogue box select ASP.NET web service.

2-     Put name in name text box.

3-     Add a reference to domobj.dll which generated at previous steps.

4-    Here, in my web service, I retrieve from domino mails the following attributes (Mail Subject, Mail Date, Recipients, From, Message ID, and Mail Body) so I have created a class called Mail subject and create all previous attribute as properties in this class.

public class MailSubject

{

public string subject;

public string body;

public string to;

public string from;

public string postedate;

public string messageid;

public string MessageID

{

get { return messageid; }

set { messageid = value; }

}

public string Subject

{

get { return subject; }

set { subject = value; }

}

}

5-     Create web method which will be consumed from custom web part

[WebMethod]

public List<MailSubject> GetLotusInbox()

{

List<MailSubject> MailsSubjectlist = new List<MailSubject>();

MailSubject MailObject = new MailSubject();

try

{

NotesSession NS = new NotesSession();

NotesDocumentCollection NCollection;

NotesDbDirectory NDBD;

NotesDatabase NDB;

NS.Initialize(“P@ssw0rd”);

NDBD = NS.GetDbDirectory(“”);

NDB = NDBD.OpenMailDatabase();

NotesView NV;

NV = NDB.GetView(“($Inbox)”);

NotesViewEntryCollection ViewsCollection = NV.AllEntries;

for (int i = 0; i <= ViewsCollection.Count; i++)

{

NotesDocument doc = ViewsCollection.GetNthEntry(i).Document;

object docitems = doc.Items;

Array itemsarr = (Array)docitems;

for (int j = 0; j <= itemsarr.Length; j++)

{

try

{

NotesItem ni = (NotesItem)itemsarr.GetValue(j);

if (ni.Name == “Subject”)

MailObject.subject = ni.Text;

if (ni.Name == “Body”)

MailObject.body = ni.Text;

if (ni.Name == “SendTo”)

MailObject.to = ni.Text;

if (ni.Name == “$MessageID”)

MailObject.messageid = ni.Text;

if (ni.Name == “From”)

MailObject.from = ni.Text;

if (ni.Name == “PostedDate”)

MailObject.postedate = ni.Text;

}

catch (Exception exc)

{

}

}

MailsSubjectlist.Add(MailObject);

}

}

catch (Exception exc)

{

}

return MailsSubjectlist;

}

When accessing the Domino Objects COM interface, it is necessary to login, or authenticate.  This is done two ways.  One way is with the “Initialize” method of the “NotesSession” class. This will work on the Notes client and the Domino Server.  The other way is using the “InitializeUsingNotesUserName” Method also off the “NotesSesson” class.

The Initialize Method takes a password string parameter.  The identity is the default person (current user or last person to login).  In the case of a server execution, identity is that of the server.

InitializeUsingNotesUserName method has an additional parameter called “User”.

This allows you to change who you  are running as by supplying User and password.  Note: the user’s certificate must be on the server for this to work.

Once logged-in, your identity is established.  So, when you execute the “OpenMailDataBase” Method, which has no parameters, the correct database is opened.

At runtime, the Lotus Notes interop fetches the data as requested using the Interop classes, i.e. NotesViewEntryCollection, NotesViewEntry and NotesDocument. These classes for Lotus Notes clients provide .NET developers with a familiar way to use Lotus Notes functionality. Using the code, developers can access Lotus Notes documents and can integrate Lotus Notes capabilities to any external applications.

Now we have created the web service which will be consumed from custom web part in SharePoint Server 2010 to display the contents of Domino Mails. Next step will be creating custom web part at SharePoint Server 2010.

ON SharePoint-Lab Server:-

 

The following software to be installed for developing custom web service:-

1-     SharePoint Server 2010.

2-     IIS 7.

3-     Microsoft IE v7or newer.

4-     Visual Studio 2010.

Once you have installed the above products, do the following steps:-

1-     Create Visual web Part Project.

2-     Add web reference, web service which we are created on Domino Server.

3-     Start initialize object of this web service and use its web method as the following

LotusInbox.Service Inbox = new LotusInbox.Service();

static LotusInbox.MailSubject[] TempMails;

protected void Button1_Click(object sender, EventArgs e)

{

CheckMails();

}

public void CheckMails()

{

try

{

LotusInbox.MailSubject[] mails = Inbox.GetLotusInbox();

TempMails = mails;

int a = mails.Length;

for (int i = 0; i < a; i++)

{

mails[i].from = mails[i].from.Substring(3, mails[i].from.IndexOf(‘/’)-3);

mails[i].to = mails[i].to.Substring(3, mails[i].to.IndexOf(‘/’) – 3);

}

GridView1.DataSource = mails;

GridView1.DataBind();

}

catch (Exception exc)

{

throw exc;

}

4-     Deploy this web part to our site collection and test it.

References:-

1-     Redbooks Paper

2-     http://www.codeproject.com/KB/cs/lotusnoteintegrator/WindowsApplication2.zip

 

 

 

 

 

Advertisements
  1. Hit_dal
    August 19, 2011 at 10:56 am

    Nice informative article.
    Is the suggested technique capable of maintaining the content with “Rich Text Format”, identify attachments?

  2. March 14, 2012 at 7:08 am

    yes , you can do all the capabilities with this technique

  1. No trackbacks yet.

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

%d bloggers like this: