VS2008开发Outlook 附件检查!
比较简单,没有什么好说的!
1
using System;
2
using System.Collections.Generic;
3
using System.Text;
4
using Outlook = Microsoft.Office.Interop.Outlook;
5
using Office = Microsoft.Office.Core;
6
using System.Windows.Forms;
7![](/Images/OutliningIndicators/None.gif)
8
namespace OutlookAddInAttachmentCheck
9
{
10
public partial class ThisAddIn
11
{
12
private void ThisAddIn_Startup(object sender, System.EventArgs e)
13
{
14
//this.Application.ItemSend
15
this.Application.ItemSend += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend);
16
}
17![](/Images/OutliningIndicators/InBlock.gif)
18
void Application_ItemSend(object Item, ref bool Cancel)
19
{
20
if( Item is Outlook.MailItem)
21
{
22
Outlook.MailItem myItem = (Outlook.MailItem)Item;
23
24
if (myItem.Body.IndexOf("附件") > -1|| myItem.Body.ToUpper().IndexOf("ATTACHMENT")>-1)
25
{
26
if (myItem.Attachments.Count == 0)
27
{
28
MessageBox.Show("请添加附件,因为您在邮件中提到附件!", "提醒!", MessageBoxButtons.OK);
29
Cancel = true;
30
}
31
}
32![](/Images/OutliningIndicators/InBlock.gif)
33![](/Images/OutliningIndicators/InBlock.gif)
34
}
35
36
}
37![](/Images/OutliningIndicators/InBlock.gif)
38
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
39
{
40
}
41![](/Images/OutliningIndicators/InBlock.gif)
42![](/Images/OutliningIndicators/InBlock.gif)
43![](/Images/OutliningIndicators/InBlock.gif)
44
VSTO generated code
57
}
58
}
59![](/Images/OutliningIndicators/None.gif)
1
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/None.gif)
8
![](/Images/OutliningIndicators/None.gif)
9
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
10
![](/Images/OutliningIndicators/InBlock.gif)
11
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
12
![](/Images/OutliningIndicators/InBlock.gif)
13
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
14
![](/Images/OutliningIndicators/InBlock.gif)
15
![](/Images/OutliningIndicators/InBlock.gif)
16
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
17
![](/Images/OutliningIndicators/InBlock.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
20
![](/Images/OutliningIndicators/InBlock.gif)
21
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
22
![](/Images/OutliningIndicators/InBlock.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/InBlock.gif)
25
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
26
![](/Images/OutliningIndicators/InBlock.gif)
27
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
28
![](/Images/OutliningIndicators/InBlock.gif)
29
![](/Images/OutliningIndicators/InBlock.gif)
30
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
31
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
32
![](/Images/OutliningIndicators/InBlock.gif)
33
![](/Images/OutliningIndicators/InBlock.gif)
34
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
35
![](/Images/OutliningIndicators/InBlock.gif)
36
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
37
![](/Images/OutliningIndicators/InBlock.gif)
38
![](/Images/OutliningIndicators/InBlock.gif)
39
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
40
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
41
![](/Images/OutliningIndicators/InBlock.gif)
42
![](/Images/OutliningIndicators/InBlock.gif)
43
![](/Images/OutliningIndicators/InBlock.gif)
44
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
57
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
58
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
59
![](/Images/OutliningIndicators/None.gif)