Outlook .MSG文件包含许多收件人,然后“收件人”属性变为空白,返回null

时间:2019-06-07 15:04:35

标签: c# .net outlook

当尝试使用dll Microsoft.Office.Interop.Outlook 15.0.0.0版的.net读取.Net中的 .msg 文件时,遇到读取大收件人时遇到的问题。

场景:

  1. 如果.msg文件包含的收件人较少(例如,少于300个),则To属性中的值将显示实际收件人。
  2. 如果.msg文件具有300个以上的收件人,则To对象的MailItem属性将得到null的显示为空白。

图书馆对收件人的阅读有任何限制吗?或者我缺少处理更多收件人的任何东西?

    Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application();
    Microsoft.Office.Interop.Outlook.Application();

    var item = app.Session.OpenSharedItem(msgfilepath) as Microsoft.Office.Interop.Outlook.MailItem;
    string message = item.Body
    string recipients = item.To   
   //This To property gets null in case file has large recipients list.

1 个答案:

答案 0 :(得分:1)

更改:

    // Selecting every fieldset available
    const formPart = document.getElementsByTagName('fieldset')

    // Selecting every button available
    const buttons = document.getElementsByTagName('a')

    // Checking the active fieldset with formNumber
    let formNumber = 0
    let formPartActive = formPart[formNumber]
    formPartActive.className = 'show'

    // Checks the amount of fieldsets and duplicates the HTML string for the bullet as many times  as there are fieldsets
    let bulletNumber = "<div class='bullet'></div>"
    const formLength = formPart.length
    for (let i = 1; i < formLength; i++) {
      bulletNumber += "<div class='bullet'></div>"

      // Hide the fieldsets (formParts) if the Javascript is running
      formPart[i].className = 'hide'

      // Changes the hide class to show to display the buttons if the Javascript is running
      for (let x = 0; x < buttons.length; x++) {
        buttons[x].className = 'show'
      }
    }

    // Checks the amount of bulletContainers and injects the bullets necessery (see the loop above) into each one
    const bulletContainer = document.getElementsByClassName('bullet-container')
    for (let i = 0; i < bulletContainer.length; i++) {
      const bulletContainerCount = bulletContainer[i]
      bulletContainerCount.innerHTML = bulletNumber
    }

    // Removes the previous button on first fieldset and removes the next buton on the last fieldset
    document.getElementsByName('back')[0].className = 'hide'
    document.getElementsByName('next')[bulletContainer.length - 1].className = 'hide'

    // Makes the first dot active
    const bullet = document.getElementsByClassName('bullet')
    bullet[formNumber].className += ' bullet-active'

    // Function to go to the next fieldset (formPart) and change the bullet active to the next one
    function nextStep () {
      let fieldset = document.querySelectorAll('fieldset')[formNumber]

      // Hides the current fieldset and reveales the NEXT one with the class show
      fieldset.className = 'hide'
      formNumber = formNumber + 1
      fieldset = formPart[formNumber]
      fieldset.className = 'show'

      // Makes the next bullet active
      bullet[formNumber].className += ' bullet-active'
    }

    // Hides the current fieldset and reveales the PREVIOUS one with the class show
    function previousStep () {
      formPart[formNumber].className = 'hide'
      formNumber = formNumber - 1
      formPart[formNumber].className = 'show'
    };

对此:

for(var foldcont_index in foldcont) {

    var foldit= foldcont[foldcont_index];

    if(foldit.isDirectory()) { loadBFiles(fold+'/'+foldit.name); }

    if(foldit.isFile()) {

      var buigltf= fs.readFileSync(fold+'/'+foldit.name, 'utf8');
      loader.parse(
          buigltf,
          undefined,
          function(o) {
             var oname= // !!! before issue with foldit.name
             objectstank['xxx_'+oname]= o;
             loadpoint= loadpoint+loadpercentage;
             loadbar.set(loadpoint);
             if(loadpoint>= 100) { document.getElementById("load-bar").style.display= 'none'; },
          undefined
          }
        );

    }

}

结果将是相同的以分号分隔的字符串,但第二个将始终有效。

官方文档没有讨论.To属性的限制,但确实告诉您使用收件人: https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.interop.outlook._mailitem.to