我写了一个VBA脚本,它目前只在outlook中打开的第一个收件箱中运行。
如何指定操作哪个收件箱?即,另一个帐户的收件箱。
我假设在这里 -
Sub MoveAgedMail()
Dim objOutlook As Outlook.Application
Dim objNamespace As Outlook.NameSpace
Dim objSourceFolder As Outlook.MAPIFolder
Dim objDestFolder As Outlook.MAPIFolder
Dim objVariant As Variant
Dim lngMovedItems As Long
Dim intCount As Integer
Dim intDateDiff As Integer
Dim strDestFolder As String
答案 0 :(得分:1)
即另一个帐户的收件箱。
假设您正在谈论共享收件箱
VBA示例代码将
Option Explicit
Sub OpenShareInbox()
Dim olNameSpace As Outlook.NameSpace
Dim olRec As Outlook.Recipient
Dim olFolder As Outlook.Folder
Set olNameSpace = Application.GetNamespace("MAPI")
Set olRec = olNameSpace.CreateRecipient("Om3r@Email.com") '// Owner's email address
Set olFolder = olNameSpace.GetSharedDefaultFolder(olRec, olFolderInbox)
MsgBox olRec.Name '// Owner Name
olFolder.Display '// Open Inbox
End Sub
修改:
这是另一个示例 - 打开您的即时窗口并打印主题行
Option Explicit
Sub OpenShareInbox()
Dim olNameSpace As Outlook.NameSpace
Dim olRec As Outlook.Recipient
Dim olFolder As Outlook.Folder
Dim olItem As Outlook.MailItem
Set olNameSpace = Application.GetNamespace("MAPI")
Set olRec = olNameSpace.CreateRecipient("Om3r@Email.com") '// Owner's email address
Set olFolder = olNameSpace.GetSharedDefaultFolder(olRec, olFolderInbox) '// Inbox
For Each olItem In olFolder.Items
Debug.Print olItem.Subject
Next
End Sub
或使用主题行“报告”转发邮件物品
For Each olItem In olFolder.Items
If olFolder.DefaultItemType = olMailItem Then
If olItem.Class = olMail Then
If olItem.Subject = "Report" Then
Set olItem = olItem.Forward
olItem.Subject = "APPENDED SUBJECT - " + olItem.Subject + ""
olItem.Recipients.Add "Om3r <Om3r@Email.com>"
olItem.Display
' olItem.Send
End If
End If
End If
Next
请参阅NameSpace.GetSharedDefaultFolder
Method (Outlook)on MSDN