从非默认收件箱接收电子邮件? [英] Get email from non default inbox?
问题描述
我正在使用以下 vba 代码从我的收件箱文件夹中获取电子邮件,并将它们移动到名为供应商的子文件夹中.目前,电子邮件已从我的默认电子邮件收件箱中移出,但我有一个名为 purcashing@hewden.co.uk 的帐户,我希望它从此收件箱中获取电子邮件并将其移至此帐户中名为供应商"的子文件夹中.
I am using the following vba code to get emails from my inbox folder and move them to a sub folder called suppliers. At the moment the emails are moved from my default email inbox, but I have an account called purcashing@hewden.co.uk and I want it to get the emails from this inbox and move it to the subfolder called Suppliers in this account.
有人可以告诉我如何更改 GetDefaultFolder 来实现这一点.谢谢
can someone show me how I would alter GetDefaultFolder to make this happen. thanks
Sub MoveItems()
Dim myNameSpace As Outlook.NameSpace
Dim myInbox As Outlook.Folder
Dim myDestFolder As Outlook.Folder
Dim myItems As Outlook.Items
Dim myItem As Object
Set myNameSpace = Application.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItems = myInbox.Items
Set myDestFolder = myInbox.Folders("Supplier")
Set myItem = myItems.Find("[Subject] = 'Introduction'")
While TypeName(myItem) <> "Nothing"
myItem.Move myDestFolder
Set myItem = myItems.FindNext
Wend
End Sub
推荐答案
不要使用 Namespace.GetDefaultFolder,而是从 Namespace.Stores 集合中检索适当的存储并使用 Store.GetDefaultFolder.
Instead of using Namespace.GetDefaultFolder, retrieve the appropriate store from the Namespace.Stores collection and use Store.GetDefaultFolder.
这篇关于从非默认收件箱接收电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!