【问题标题】:How to get file attachments from nested emails using EWS API如何使用 EWS API 从嵌套电子邮件中获取文件附件
【发布时间】:2017-11-18 11:22:04
【问题描述】:

我正在尝试从包含电子邮件作为附件的电子邮件中获取所有附件。我需要以某种方式递归附件以找到所有文件附件。

例如,我有一封包含 2 个附件的电子邮件。第一个附件是一个文件。其次是另一封电子邮件。这第二封电子邮件也有 2 个附件。第一个附件是一个文件。第二是第三封电子邮件。这第三封电子邮件只有一个附件,即文件。所以我需要结束 3 个文件附件,但不知道如何循环通过这个。

道格

【问题讨论】:

    标签: vb.net exchangewebservices email-attachments


    【解决方案1】:

    这是一个递归解决方案:

    Private Function GetFileAttachments(aItem As Item) As IEnumerable(Of FileAttachment)
    
        Dim result = New List(Of FileAttachment)
    
        For Each att In aItem.Attachments
    
            If TypeOf att Is ItemAttachment Then
    
                Dim itemAttachment = CType(att, ItemAttachment)
                itemAttachment.Load()
                result.AddRange(GetFileAttachments(itemAttachment.Item))
    
            Else
    
                result.Add(att)
    
            End If
    
        Next
    
        Return result
    
    End Function
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-18
      • 2020-07-04
      • 1970-01-01
      • 2019-09-13
      • 2015-04-05
      • 2020-11-06
      • 1970-01-01
      • 2018-08-31
      相关资源
      最近更新 更多