将阅读邮件移动到Outlook中的新文件夹中 [英] Moving read mail into new folders in outlook

查看:188
本文介绍了将阅读邮件移动到Outlook中的新文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  • 电子邮件收件箱

  • 电子邮件阅读

  • 所有阅读的电子邮件都被移动到_Reviewed文件夹

  • 某些电子邮件会根据事情自动移动到特定的文件夹像主题,收件人或发件人

  • Email comes to inbox
  • Email gets read
  • All read emails get moved to a "_Reviewed" folder
  • Certain emails automatically gets moved to a specific folder based upon things like subject, recipients or sender

我是新手编程,非常新的编写脚本。

I am new to programming and very new to writing scripts.

我正在尝试编写脚本的主要部分,将每个读取消息移动到我的_Reviewed文件夹。但是我不断收到这个错误

I am trying to write the main part of the script which would move every read message to my "_Reviewed" folder. But I keep getting this error

当我打了调试它带我到线路

When I hit debug it brings me to the line

Set objFolderDst = objFolderSrc.folders("__Reviewed")



我不知道是什么导致错误。这是我的整个代码。



I'm not sure whats causing the error. Here is my whole code.

Sub ReadMailMover()  

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolderSrc = objNamespace.GetDefaultFolder(olFolderInbox)
Set objFolderDst = objFolderSrc.folders("__Reviewed")  

Set colItems = objFolderSrc.Items
Set colfiltereditems = colItems.Restrict("[UnRead] = False")  

For intMessage = colfiltereditems.Count To 1 Step -1
colfiltereditems(intMessage).Move objFolderDst
Next


End Sub

我认为,在我得到这个之后,我可以得到其余的脚本,因为它应该只是这个的重复部分。

I think that after I get this that I can get the rest of the script as it should just be repeated parts of this one.

< img src =https://i.stack.imgur.com/vdmmJ.pngalt =文件树>

编辑
将@ToFile更改为__Reviewed,这是我拥有的。我不小心从较早的草稿中复制了代码。

Edits Changed @ToFile to __Reviewed which is what I had it as. I accidentally copied the code out of an earlier draft.

添加了文件树的图片。 __Reviewed不是收件箱的子文件夹。

Added pic of file tree. __Reviewed is not a sub folder to the inbox.

Sub ReadMailMover()

Set objOutlook = CreateObject("Outlook.Application")  
Set objNamespace = objOutlook.GetNamespace("MAPI")  
Set objFolderSrc = objNamespace.GetDefaultFolder(olFolderInbox)  
Set objFolderDst = objFolderSrc.Parent.folders("__Reviewed")  

Set colitems = objFolderSrc.Items  
Set colfiltereditems = colitems.Restrict("[UnRead] = False")  

For intMessage = colfiltereditems.Count To 1 Step -1  
colfiltereditems(intMessage).Move objFolderDst  
Next  

End Sub  


推荐答案

当__Reviewed与收件箱位于同一级别时, '必须访问父属性:

When __Reviewed is on the same level as your Inbox, then you'd have to access the Parent property:

Set objFolderDst = objFolderSrc.Parent.Folders("__Reviewed") 

MSDN参考

这篇关于将阅读邮件移动到Outlook中的新文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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