C # Simple Operation Lotus Notes mail

Source: Internet
Author: User
Tags mail

A short time ago a brief study. NET Operations Lotus Notes messages, including the reading and sending of messages, and the inclusion of attachments, referring to the use of IBM Lotus Domino in Microsoft. NET applications, now share the results with you. This article will be divided into three parts for getting a list of users, sending a message, receiving a message, and providing a download of the sample program (Visual Studio 2008) at the end of the article.

Reference

If you want to use. NET Operation Lotus, we can use Lotus Domino Objects to access the Domino object through COM, either on the Domino server or on any of the Notes clients (IBM Lotus Domino Designer, Lotus D Lotus Domino Objects is included in the installation of Omino Administrator or Lotus Notes. If your development environment is compounded by the above requirements, you can add a COM reference: Lotus Domino Objects, and then:

Using Domino;

If you cannot find this COM component, you can register the following components before you can find:

regsvr32 "C:\Program Files\lotus\notes\nlsxbe.dll"

Get the Notes mailbox user list

This code will traverse all users in the user view (People view) and add their full names to the ComboBox control. Create a new two global variable (global to use for other methods in this example).

Notessession NS;

NotesDatabase NDB;

Send mail

This code falls to the user selected from ComboBox to send a message, we can enter the message title and content, and can add attachments.

 try 
{
if (ns!=null)
{
NotesDocument doc = NDB. CreateDocument ();
Doc. Replaceitemvalue ("Form", "Memo");
//Recipient information
Doc. Replaceitemvalue ("SendTo", Cb_people.text);
//Mail subject
Doc. Replaceitemvalue ("Subject", Tb_subject.text);
//message body
Notesrichtextitem RT = doc. Createrichtextitem ("body");
Rt. AppendText (Tb_body.text);
//Attachment
if (!string. IsNullOrEmpty (Tb_attachment.text))
{
Notesrichtextitem attachment = doc. Createrichtextitem ("attachment");
Attachment. Embedobject (Embed_type. Embed_attachment, "", Tb_attachment.text, "attachment");
}
//Send Message
Object obj = Doc. GetItemValue ("SendTo");
Doc. Send (False,ref obj);
doc = null;
MessageBox.Show ("successfully!");
}
}
catch (Exception ex)
{
MessageBox.Show ("Error:" + ex.) message);
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.