用心做好每一件事情!

C# 调用Lotus Notes发送邮件

As title.

 

复制代码
 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Data;
 5 using System.Drawing;
 6 using System.Linq;
 7 using System.Text;
 8 using System.Windows.Forms;
 9 using Domino;
10 
11 namespace NetUseNotes
12 {
13     public partial class Form1 : Form
14     {
15         NotesSession NSession;
16         NotesDatabase NDataBase;
17         
18         public Form1()
19         {
20             InitializeComponent();
21         }
22         private void btnsend_Click(object sender, EventArgs e)
23         {
24             try
25             {
26                 if (NSession != null)
27                 {
28                     NotesDocument NDocument = NDataBase.CreateDocument();
29                     NDocument.ReplaceItemValue("Form", "Memo");
30                     
31                     NDocument.ReplaceItemValue("SendTo", txtToUser.Text);                   
32                     NDocument.ReplaceItemValue("Subject", txtSubject.Text);                     
33                     NotesRichTextItem rt = NDocument.CreateRichTextItem("Body");
34                     rt.AppendText(txtBody.Text);                    
35                  
36                     object obj = NDocument.GetItemValue("SendTo");
37                     NDocument.Send(false, ref obj);
38                     NDocument = null;
39                     MessageBox.Show("Successfully!");
40                 }
41             }
42             catch (Exception ex)
43             {
44                 MessageBox.Show("Error:" + ex.Message);
45             }
46         } 
47 
48         private void Form1_Load(object sender, EventArgs e)
49         {            
50             NSession = new NotesSession();
51             NSession.Initialize("UserName");            
52             NDataBase = NSession.GetDatabase("Notes Server", "names.nsf", false); 
53         }         
54     }
55 }
复制代码

 

posted @   无 影  阅读(3239)  评论(0编辑  收藏  举报
编辑推荐:
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
作者: Allen【QQ:96966 1314】 网名:无影 出处: http://www.cnblogs.com/allen0118/ 声明: 本文版权归作者和博客园共有!转载时必须保留此段声明,且在文章页面明显位置给出原文连接。
点击右上角即可分享
微信分享提示