从非默认收件箱中获取电子邮件? [英] Get email from non default inbox?

查看:76
本文介绍了从非默认收件箱中获取电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆