zoukankan      html  css  js  c++  java
  • vsto outlook 检查附件大小

      1 private Outlook.Explorer _Explorers;
    2
    3 private Outlook.Inspector _Inspectors;
    4
    5 double TotalAttachSize;
    6
    7 private void ThisAddIn_Startup(object sender, System.EventArgs e)
    8
    9 {
    10
    11 Outlook.Inspectors inspectors = this.Application.Inspectors;
    12
    13 inspectors.NewInspector +=
    14
    15 new Outlook.InspectorsEvents_NewInspectorEventHandler(
    16
    17 Inspectors_NewInspector);
    18
    19
    20
    21 foreach (Outlook.Inspector inspector in inspectors)
    22
    23 {
    24
    25 TotalAttachSize = 0;
    26
    27 Inspectors_NewInspector(inspector);
    28
    29 }
    30
    31
    32
    33
    34
    35 }
    36
    37
    38
    39 void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
    40
    41 {
    42
    43 if (Inspector.CurrentItem is Outlook.MailItem)
    44
    45 {
    46
    47
    48
    49 Outlook.MailItem mail = (Outlook.MailItem)Inspector.CurrentItem;
    50
    51
    52
    53 mail.BeforeAttachmentAdd += new Microsoft.Office.Interop.Outlook.ItemEvents_10_BeforeAttachmentAddEventHandler(mail_BeforeAttachmentAdd);
    54
    55 mail.AttachmentAdd += new Microsoft.Office.Interop.Outlook.ItemEvents_10_AttachmentAddEventHandler(mail_AttachmentAdd);
    56
    57
    58
    59 }
    60
    61
    62
    63 }
    64
    65
    66
    67
    68
    69
    70
    71 void mail_AttachmentAdd(Microsoft.Office.Interop.Outlook.Attachment Attachment)
    72
    73 {
    74
    75 int MB = 1024*1024;
    76
    77 MessageBox.Show(Attachment.Size.ToString() + "\n" + " Now Total Size limit reached is " + TotalAttachSize/MB + " MB");
    78
    79 }
    80
    81
    82
    83 void mail_BeforeAttachmentAdd(Microsoft.Office.Interop.Outlook.Attachment Attachment, ref bool Cancel)
    84
    85 {
    86
    87 TotalAttachSize =TotalAttachSize + Attachment.Size;
    88
    89 if (TotalAttachSize > (1024 * 1024 * 10 ))
    90
    91 {
    92
    93 MessageBox.Show("You have reached the total Attachment Size limit");
    94
    95 return;
    96
    97 }
    98
    99
    100
    101 }


    编辑器加载中...

  • 相关阅读:
    powershel学习(1)
    JS作用域链(转载)
    C# 对QuotedPrintable进行解码的方法
    SortedList、SortedSet、HashSet、Hashtable、Dictionary、SortedDictionary 排序/可重复排序/过滤重复排序等简单对比
    .net windows 服务中返回服务的安装目录
    c# 中图像的简单二值化处理
    windows下开多个CMD窗口多个进程输出
    生命游戏
    PowerDesigner工具简介
    七大面向对象设计原则(转)
  • 原文地址:https://www.cnblogs.com/senion/p/2320216.html
Copyright © 2011-2022 走看看