国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
C#簡單操作Lotus Notes郵件
前段時間簡單的研究了一下.NET操作Lotus Notes郵件的實(shí)現(xiàn),具體的操作包括郵件的讀取和發(fā)送,而且都要包含附件,其間參考了《在 Microsoft .NET 應(yīng)用程序中使用 IBM Lotus Domino》一文,現(xiàn)在把成果和大家分享一下。
本文將分為獲取用戶列表、發(fā)送郵件、收取郵件三個部分,并會在文末提供范例程序(Visual Studio 2008)的下載。

引用

如果想使用.NET操作Lotus,我們可以使用 Lotus Domino Objects 通過 COM 來訪問 Domino 對象,在 Domino 服務(wù)器或者任何一個 Notes 客戶機(jī)(IBM Lotus Domino Designer、Lotus Domino Administrator 或者 Lotus Notes)的安裝中都包括 Lotus Domino Objects。如果你的開發(fā)環(huán)境復(fù)合上述的要求,就可以添加一個COM引用:Lotus Domino Objects,然后:
using Domino;
如果找不到這個COM組件,可以先注冊以下組件,然后就可以找到了:

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


獲取Notes郵箱用戶列表

本段代碼將遍歷用戶視圖(People View)中的所有用戶,將其全名添加到ComboBox控件中。新建兩個全局變量(全局的目的是供本例中的其它方法使用)。
NotesSession ns;
NotesDatabase ndb;

發(fā)送郵件

本段代碼降為從ComboBox中選中的用戶發(fā)送一封郵件,我們可以輸入郵件的標(biāo)題和內(nèi)容,并可以添加附件。
try
{
    
if(ns!=null)
    {
        NotesDocument doc 
= ndb.CreateDocument();

        doc.ReplaceItemValue(
"Form""Memo");

        
//收件人信息
        doc.ReplaceItemValue("SendTo", cb_People.Text);

        
//郵件主題
        doc.ReplaceItemValue("Subject", tb_Subject.Text);

        
//郵件正文
        NotesRichTextItem rt = doc.CreateRichTextItem("Body");
        rt.AppendText(tb_Body.Text);

        
//附件
        if (!string.IsNullOrEmpty(tb_Attachment.Text))
        {
            NotesRichTextItem attachment 
= doc.CreateRichTextItem("attachment");
            attachment.EmbedObject(EMBED_TYPE.EMBED_ATTACHMENT, 
"", tb_Attachment.Text, "attachment");
        }

        
//發(fā)送郵件
        object obj = doc.GetItemValue("SendTo"); 
        doc.Send(
false,ref obj);

        doc 
= null;
        MessageBox.Show(
"Successfully!");
    }

}
catch(Exception ex)
{
    MessageBox.Show(
"Error:" + ex.Message);
}

如果想要添加多個收件人,可以將代碼:
doc.ReplaceItemValue("SendTo", cb_People.Text); 
更改為代碼:
string[] receivers = { cb_People.SelectedItem.ToString(), "windie chai/TEST" };
doc.ReplaceItemValue(
"SendTo", receivers);
如果想要添加多個附件,可以繼續(xù)調(diào)用這個對象的EmbedObject方法:
attachment.EmbedObject(EMBED_TYPE.EMBED_ATTACHMENT, """FilePath""attachment"); 

獲取收件箱內(nèi)全部郵件

為了存儲郵件內(nèi)容,我編寫了一個簡單的類:
簡單的郵件類
接著添加一個全局變量來存儲郵件集合:
public List<Mail> mails = new List<Mail>();
然后將所有郵件的信息添加的mails集合中,并將它們的標(biāo)題添加到一個ListBox中。
//清空郵件列表
lb_Mail.Items.Clear();
mails.Clear();

//獲取郵箱視圖
NotesDbDirectory dir = ns.GetDbDirectory("DominoT/TEST");
NotesDatabase maildb 
= dir.OpenMailDatabase();
NotesView nv 
= maildb.GetView("$inbox");

//遍歷所有郵件
NotesDocument doc = nv.GetFirstDocument();
while (doc != null)
{
    Mail mail 
= new Mail();
    mail.Subject 
= ((object[])doc.GetItemValue("Subject"))[0].ToString();
    mail.From 
= ((object[])doc.GetItemValue("From"))[0].ToString();
    mail.Body 
= ((object[])doc.GetItemValue("Body"))[0].ToString();
    mail.Time 
= ((object[])doc.GetItemValue("PostedDate"))[0].ToString();
    
object[] items = (object[])doc.Items;
    
foreach (NotesItem item in items)
    {
        
if (item.Name == "$FILE")
        {
            
string fileName = ((object[])item.Values)[0].ToString();
            NotesEmbeddedObject file 
= (NotesEmbeddedObject)doc.GetAttachment(fileName);
            
if (file != null)
                mail.Files.Add(file);
        }
    }

    mails.Add(mail);
    lb_Mail.Items.Add(mail.Subject);

    
//查找下一封郵件
    doc = nv.GetNextDocument(doc);
}

顯示郵件內(nèi)容并打開附件

由于前面的代碼中我已經(jīng)把郵件信息添加到自己定義的郵件集合中了,所以下面的操作就不需要和Domino服務(wù)器交互了。
本段代碼實(shí)現(xiàn)了在ListBox中點(diǎn)擊郵件標(biāo)題后在一個TextBox中顯示郵件內(nèi)容(包括標(biāo)題,時間,正文和附件文件名)。 
Mail m = mails[lb_Mail.SelectedIndex];
StringBuilder sbMail 
= new StringBuilder();
sbMail.AppendLine(m.Subject);
sbMail.AppendLine(
"----------");
sbMail.AppendLine(m.Time);
sbMail.AppendLine(
"----------");
sbMail.AppendLine(m.Body);
sbMail.AppendLine(
"----------");
sbMail.AppendLine(
"Attachments:");
foreach (NotesEmbeddedObject file in m.Files)
{
    sbMail.AppendLine(file.Name);
}
tb_Mail.Text 
= sbMail.ToString();

//根據(jù)附件數(shù)量決定打開附件按鈕是否可用
if(m.Files.Count>0)
{
    btn_OpenAttachment.Enabled 
= true;
}
else
    btn_OpenAttachment.Enabled 
= false;
本段代碼實(shí)現(xiàn)了當(dāng)點(diǎn)擊“打開附件”按鈕后從內(nèi)從中釋放附件文件到硬盤并執(zhí)行它。
Mail m = mails[lb_Mail.SelectedIndex];

//獲取第一個附件
NotesEmbeddedObject file = m.Files[0];

//組合一個臨時路徑
string filename = Path.Combine(Application.StartupPath,file.Name);

//將附件釋放到臨時路徑
file.ExtractFile(filename);

//執(zhí)行附件
System.Diagnostics.Process.Start(filename);
主要的代碼就這么多了,第一次使用IBM的軟件,感覺……很不順手,連對象模型都相當(dāng)別扭,嗯,廢話不說了 ,如果上面的代碼有何不恰當(dāng)?shù)牡胤竭€請各位朋友多多指教。
點(diǎn)擊這里下載本文的范例程序(Visual Studio 2008),范例程序的UI如下:

點(diǎn)擊“Sender”之后回到Notes中,刷新發(fā)現(xiàn)郵件已經(jīng)收到,包含附件,并且可以正常打開:
原文發(fā)布于coding.windstyle.cn,歡迎訪問、訂閱并和我交流。
 

進(jìn)入 " Visual Studio 2005 命令提示"

C:\Lotus\Notes>sn -k LotusNotes.snk

C:\Lotus\Notes>sn -p LotusNotes.snk LotusNotesPublic.snk

C:\Lotus\Notes>sn -t LotusNotesPublic.snk

C:\Lotus\Notes>tlbimp domobj.tlb /keyfile:Lotusnotes.snk

Microsoft (R) .NET Framework Type Library to Assembly Converter 2.0.50727.42

Copyright (C) Microsoft Corporation. All rights reserved.

   

Type library imported to Domino.dll

   

再把Domino.dll 拖到Windows\assembly (GAC) 目錄下.實(shí)現(xiàn)部署.

   

   

   

網(wǎng)站中要使用Notes 必須在Server 上進(jìn)行以下權(quán)限設(shè)置:

  1. Lotus 目錄進(jìn)行權(quán)限設(shè)定:

    Domain Users Users 加上寫的權(quán)限.

       

       

   

Tlbimp 命令

C:\Lotus>tlbimp

Microsoft (R) .NET Framework Type Library to Assembly Converter 2.0.50727.42

Copyright (C) Microsoft Corporation. All rights reserved.

   

Syntax: TlbImp TypeLibName [Options]

Options:

/out:FileName File name of assembly to be produced

/namespace:Namespace Namespace of the assembly to be produced

/asmversion:Version Version number of the assembly to be produced

/reference:FileName File name of assembly to use to resolve references

/tlbreference:FileName File name of typelib to use to resolve references

/publickey:FileName File containing strong name public key

/keyfile:FileName File containing strong name key pair

/keycontainer:FileName Key container holding strong name key pair

/delaysign Force strong name delay signing

/unsafe Produce interfaces without runtime security checks

/noclassmembers Prevents TlbImp from adding members to classes

/nologo Prevents TlbImp from displaying logo

/silent Suppresses all output except for errors

/verbose Displays extra information

/primary Produce a primary interop assembly

/sysarray Import SAFEARRAY as System.Array

/machine:MachineType Create an assembly for the specified machine type

/transform:TransformName Perform the specified transformation

/strictref Only use assemblies specified using /reference and

registered PIAs

/strictref:nopia Only use assemblies specified using /reference and

ignore PIAs

/? or /help Display this usage message

   

The assembly version must be specified as: Major.Minor.Build.Revision.

   

Multiple reference assemblies can be specified by using the /reference option

multiple times.

   

Supported machine types:

X86

X64

Itanium

Agnostic

   

Supported transforms:

SerializableValueClasses Mark all value classes as serializable

DispRet Apply the [out, retval] parameter transformation

to methods of disp only interfaces

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
尚易企業(yè)郵箱客戶服務(wù)-Lotus notes 設(shè)置指南-如何在Lotus notes 6....
LotusNotes電子郵箱應(yīng)用技巧(1)-多用戶郵箱的煩惱(下)
Lotus課程內(nèi)容介紹>>無憂題庫網(wǎng)
Configuring Gmail POP on Lotus Notes — Dharwa...
解決Notes不需重新安裝的問題
Louts Notes學(xué)習(xí)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服