我遇到了问题,无法将有效电子邮件移至收件箱中的子文件夹。 需要将(“ xxxx@xxx.xxx”)替换为olFolderInbox或inbox等,而无需在VBA代码中键入特定的电子邮件地址。
Dim objMail As Outlook.MailItem
Dim objNS As Outlook.NameSpace
Dim objFolderItem As Outlook.Folder
Set objNS = Application.GetNamespace("MAPI")
Set objFolderItem = objNS.Folders.Item("xxxx@xxx.xxx").Folders.Item("tmp")
objMail.Move objMoveItem
答案 0 :(得分:0)
尝试一下
Option Explicit
Public Sub Exampls()
Dim olNs As Outlook.NameSpace
Set olNs = Application.GetNamespace("MAPI")
Dim Inbox As Outlook.MAPIFolder
Set Inbox = olNs.GetDefaultFolder(olFolderInbox)
Dim Item As MailItem
Set Item = ActiveExplorer.selection(1)
Item.Move Inbox.Folders("Temp")
End Sub