“Method 'body' of object'_mailItem' failed” error in Excel and Outlook 2016

后端 未结 1 1034
执笔经年
执笔经年 2021-01-25 16:18

I wrote a program in Excel 2010 to sift through emails in a selected Outlook 2010 folder, and pull in information from the email (html) body.

I updated to Office 2016. S

1条回答
  •  野的像风
    2021-01-25 16:46

    Avoid using multiple dot notation and check if you really have a MailItem object (you can also have ReportItem or MeetingItem):

    set items = FormFolder.Items
    For i = 1 To items.Count
      set item = items.Item(i)
      if item.Class = 43 Then
        Range("A2").Select
        ActiveCell.Value = item.Subject
        ActiveCell.Offset(0, 1).Value = item.To
      End If
      set item = Nothing
    next
    set items = Nothing
    

    0 讨论(0)
提交回复
热议问题