我在线找到了以下脚本,并尝试进行修改,但是没有运气。我希望此Outlook宏检查颜色类别而不是标记的电子邮件。因此,例如,它不会检查是否标记了电子邮件,然后将详细信息导出到excel,但会导出所有电子邮件,并在有关电子邮件标记的类别(名称)的第6列中添加一个额外的列。
这是在Outlook中处理电子邮件的代码
Sub ProcessMailFolders(ByVal objCurrentFolder As Outlook.Folder)
Dim i As Long
Dim objMail As Outlook.MailItem
Dim objFlaggedMail As Outlook.MailItem
Dim nLastRow As Integer
Dim objSubfolder As Outlook.Folder
For i = 1 To objCurrentFolder.Items.Count
If objCurrentFolder.Items(i).Class = olMail Then
'Export the information of each flagged email to Excel
Set objMail = objCurrentFolder.Items(i)
If objMail.IsMarkedAsTask = True And objMail.FlagStatus <> olFlagComplete Then
Set objFlaggedMail = objMail
With objExcelWorksheet
nLastRow = .Range("A" & .Rows.Count).End(xlUp).Row + 1
.Range("A" & nLastRow) = objFlaggedMail.Subject
.Range("B" & nLastRow) = objFlaggedMail.TaskStartDate
.Range("C" & nLastRow) = objFlaggedMail.TaskDueDate
.Range("D" & nLastRow) = objFlaggedMail.SenderName
.Range("E" & nLastRow) = objFlaggedMail.To
End With
End If
End If
Next i
If objCurrentFolder.Folders.Count > 0 Then
For Each objSubfolder In objCurrentFolder.Folders
Call ProcessMailFolders(objSubfolder)
Next
End If
End Sub
我能够修改的代码指的是Excel,但没有深入检查分类而不是标记电子邮件。
答案 0 :(得分:1)
您需要更改'if'语句。邮件项目具有称为类别的属性,该属性返回字符串。 更改:
If objMail.IsMarkedAsTask = True And objMail.FlagStatus <> olFlagComplete Then
收件人:
If objMail.Categories = ***Insert Category Name In Quotes*** Then