0

我正在尝试从我的电子邮件中提取像表格一样设置的数据。有谁知道我如何遍历电子邮件内容以检查表格,以及是否将数据导出到 Excel 中的列?现在,我刚刚返回的代码返回主题、发件人和发送时间。

Sub GetMCInboxLeads()

    Dim ol As Outlook.Application
    Dim ns As Outlook.Namespace
    Dim fol As Outlook.Folder
    Dim i As Object
    Dim mi As Outlook.MailItem         
    Dim n As Long 
    Dim rh As Double
    Dim objOwner As Outlook.Recipient

    Set ol = New Outlook.Application
    Set ns = ol.GetNamespace("MAPI")
    Set fol = ns.GetDefaultFolder(olFolderInbox)
    Set objOwner = ns.CreateRecipient("xx@xxx.com")
    objOwner.Resolve

    If objOwner.Resolved Then
        Set fol = ns.GetSharedDefaultFolder(objOwner, olFolderInbox)
    End If

    Worksheets.Add
    rh = Range("A1").RowHeight
    'i = 1

    For Each i In fol.Items

        If i.Class = olMail Then

            n = n + 1 

            Set mi = i
            'Debug.Print mi.Subject, mi.SenderName, mi.ReceivedTime

            Cells(n, 1).Value = mi.SenderName
            Cells(n, 2).Value = mi.Subject
            Cells(n, 3).Value = mi.ReceivedTime
            Cells(n, 4).Value = mi.Body
        End If

    Next i


    Range("A1").CurrentRegion.EntireColumn.AutoFit
    Range("A1").CurrentRegion.EntireRow.RowHeight = rh
4

0 回答 0