Outlook:将来自一个发件人的所有电子邮件合并到一个Word文件中? [英] Outlook: Combining all emails from one sender into a Word file?
问题描述
Hi,
我想知道你是否可以合并所有电子邮件(只是身体和主题;没有附件,签名,法律免责声明等)从一个发件人到一个Word文件?
I am wondering if you can combine all emails (just the body and subject; no attachment, signature, legal disclaimers, etc.) from one sender into one Word file?
有没有办法在VBA中执行此操作?
Is there a way to do this in VBA?
非常感谢。
Thanks very much.
推荐答案
有一种方法可以使用ONLY WORD来做到这一点,但是我不要想到怎么做。 可能,下一个最好的事情是将数据导出到Excel,并在Excel中应用过滤器。 然后你可以用它做任何你想做的事情,比如导出到Word
表,或者你想要做的任何事情...
There is probably a way to use ONLY WORD to do this, but I can't think of how to do that. Probably, the next best thing is to export the data to Excel, and apply a filter in Excel. Then you can do whatever you want with it, like export to a Word table, or whatever else you want to do...
Sub Scan_my_outlook_inbox()
'TOOLS ->Refrence -> microsoft outlook
'declare outlook objects
Dim olapp As Outlook.Application
Dim olappns As Outlook.Namespace
Dim oinbox As Outlook.Folder
Dim oitem As Outlook.MailItem
Dim myItems As Outlook.Items
Dim i As Long
i = 2
'set outlook objects
Set olapp = New Outlook.Application
Set olappns = olapp.GetNamespace("MAPI")
' it will scan inbox folder only
Set oinbox = olappns.GetDefaultFolder(olFolderInbox)
' check if any unread email in inbox
If oinbox.Items.Restrict("[UnRead] = True").Count = 0 Then
MsgBox "NO Unread Email In Inbox"
Exit Sub
End If
' sort emails on recieved basis
Set myItems = oinbox.Items
myItems.Sort "[Received]", True
'loop through all unread emails
For Each oitem In myItems.Restrict("[UnRead] = True")
Sheets("Inbox Scan").Cells(i, 1).Value = oitem.SenderName
Sheets("Inbox Scan").Cells(i, 2).Value = oitem.SenderEmailAddress
Sheets("Inbox Scan").Cells(i, 3).Value = oitem.Subject
Sheets("Inbox Scan").Cells(i, 4).Value = oitem.Body
Sheets("Inbox Scan").Cells(i, 5).Value = oitem.ReceivedTime
i = i + 1
Next
End Sub
这篇关于Outlook:将来自一个发件人的所有电子邮件合并到一个Word文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!