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 }


    编辑器加载中...

  • 相关阅读:
    Python IDE
    Codeforces Beta Round #69 Div1
    HDU1595 find the longest of the shortest[最短路]
    MFC/OpenGL下的调色板
    ApacheCN 编程/大数据/数据科学/人工智能学习资源 2019.12
    计算机电子书 2016 BiliDrive 备份
    计算机电子书 2017 BiliDrive 备份
    Java项目中常见的异常处理
    从小工到专家第三次读后感
    《梦断代码》读后感1
  • 原文地址:https://www.cnblogs.com/senion/p/2320216.html
Copyright © 2011-2022 走看看