我正在尝试使用Redemption为Outlook编写VB脚本。我的任务如下:
我已经确定Redemption是最容易使用的,因为它允许您检查附件而无需保存并打开它们。我有以下工作,它将告诉我所选电子邮件附加信息的信息。
$stateProvider.state('myState', {
parent: 'baseState',
url: '/calendar?firstAvailableDate',
template: 'calendar.html',
controller: 'CalendarController',
controllerAs: 'calendarCtrl',
redirectTo: (trans) => {
if (trans.params().firstAvailableDate === '') {
var CalendarService = trans.injector().get('CalendarService');
return CalendarService.getAvailableDates().then(function(response){
return { state: 'myState', params: { firstAvailableDate: response[0] }};
});
}
}
});
我还没有找到一种方法来通过我的收件箱中的每个项目。但是我已经能够通过收件箱中的电子邮件循环来获取主题。
Sub GetAttachmentInfo()
Dim olApp As Outlook.Application
Set olApp = CreateObject("Outlook.Application")
Dim olNS As Outlook.NameSpace
Set olNS = olApp.GetNamespace("MAPI")
Dim FolderSrc As MAPIFolder
Set FolderSrc = CreateObject("Outlook.Application"). _
GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
Dim oRDOSession As Redemption.RDOSession
Set oRDOSession = CreateObject("Redemption.RDOSession")
oRDOSession.MAPIOBJECT = olNS.Application.Session.MAPIOBJECT
Set Inbox = oRDOSession.GetDefaultFolder(olFolderInbox)
Set Mail = olApp.ActiveExplorer.Selection.Item(1)
Debug.Print "EntryID: " & Mail.EntryID
Set Mail = oRDOSession.GetMessageFromID(Mail.EntryID)
For Each Msg In FolderSrc.Items
For Each att In Mail.Attachments
Debug.Print "Sender: " & att.EmbeddedMsg.SenderEmailAddress
Debug.Print "Embedded Msg Subject: " & att.EmbeddedMsg
Next
Next
End Sub
我知道基本想法只是一个
Sub subjectLine()
Dim olApp As Outlook.Application
Set olApp = CreateObject("Outlook.Application")
Dim Folder As Object
Dim olNS As Outlook.NameSpace
Set olNS = olApp.GetNamespace("MAPI")
Dim oRDOSession As Redemption.RDOSession
Set oRDOSession = CreateObject("Redemption.RDOSession")
oRDOSession.MAPIOBJECT = olNS.Application.Session.MAPIOBJECT
Set Folder = Session.GetDefaultFolder(olFolderInbox)
For Each Msg In Folder.Items
Debug.Print (Msg.Subject)
Next
End Sub
有人可以就如何做到这一点提出建议吗?
答案 0 :(得分:0)
在您的第一个脚本中,您已经遍历收件箱中的所有项目,但您从未触摸过它们 - 您正在不断处理所选邮件的附件。在行
For Each att In Mail.Attachments
用Msg替换Mail。您还需要确保触摸嵌入的邮件附件。在我的头顶:
For Each Msg In FolderSrc.Items
For Each att In Msg .Attachments
if att.Type = 5 Then 'olEmbeddedItem
set embeddedMsg = att.EmbeddedMsg
Debug.Print "Sender: " & embeddedMsg.SenderEmailAddress
Debug.Print "Embedded Msg Subject: " & embeddedMsg.Subject
End If
Next
Next