vba - 设置电子邮件类别
问题描述
随着循环的进行,我正在尝试为每封电子邮件添加一个类别:
Option Explicit
Sub SaveAttachmentsFromSelectedItemsPDF2_ForNext()
Dim currentItem As Object
Dim currentAttachment As Attachment
Dim saveToFolder As String
Dim savedFileCountPDF As Long
Dim i As Long
Dim j As Long
saveToFolder = "c:\dev\outlookexport" 'change the path accordingly
savedFileCountPDF = 0
For i = 1 To ActiveExplorer.Selection.Count
Set currentItem = ActiveExplorer.Selection(i)
For j = 1 To currentItem.Attachments.Count
Set currentAttachment = currentItem.Attachments(j)
If UCase(Right(currentAttachment.DisplayName, 5)) = UCase(".xlsx") Then
currentAttachment.SaveAsFile saveToFolder & "\" & _
Left(currentAttachment.DisplayName, Len(currentAttachment.DisplayName) - 5) & ".xlsx"
savedFileCountPDF = savedFileCountPDF + 1
End If
' If For Next does not release memory automatically then
' uncomment to see if this has an impact
'Set currentAttachment = Nothing
Next
' If For Next does not release memory automatically then
' uncomment to see if this has an impact
'Set currentItem = Nothing
Next
MsgBox "Number of PDF files saved: " & savedFileCountPDF, vbInformation
End Sub
设置类别的代码似乎是:
.Categories = "MyCategory"
当我将它添加到我的代码(在 下For i = 1...
)时,它给了我一个错误:
“不合格的参考”
当循环沿着选定的电子邮件列表向下移动时,如何向电子邮件添加类别?
解决方案
您需要在代码中指定对象:
For i = 1 To ActiveExplorer.Selection.Count
Set currentItem = ActiveExplorer.Selection(i)
currentItem.Categories = "MyCategory"
Next
推荐阅读
- swift - Swift - 从更新中排除 pod 文件
- c - 堆块在 ... 修改在 ... 过去请求的大小为 4
- python - 数据框 - 将行转换为列 - 按另一列分组
- shell - 即使有效,在 zsh 中也找不到命令
- docker - Ros Docker to ROS non docker 多台机器
- html - 如何将某些身体元素移动到屏幕的不同部分?
- pycharm - 如何在 PyCharm 中启用科学模式?
- java - 并行执行 Java 线程
- javascript - 如何在带有 AJV 错误的错误消息中使用属性名称
- html - 如何使用 css 样式表“npm start”一个 html 文件?