我嘗試在 Outlook 2019 中使用 VBA 從 MailItem 創建任務。根據Attachment.Add的檔案:
位置 可選 長:此引數僅適用于使用富文本格式的電子郵件:它是附件應放置在郵件正文中的位置。Position 引數的值為 1 指定附件應位于郵件正文的開頭。大于電子郵件專案正文中字符數的值“n”指定附件應放在末尾。值 0 使附件隱藏。
但是,如果我使用位置 1(見下文),帶有原始郵件鏈接的圖示仍將位于正文的末尾而不是開頭。我錯過了什么嗎?
Sub CreateTask()
Set olApp = Outlook.Application
Set Msg = olApp.ActiveExplorer.Selection.Item(1)
Dim olTask As TaskItem
Set olTask = olApp.CreateItem(olTaskItem)
With olTask
.Subject = Msg.Subject
.RTFBody = Msg.RTFBody
.Attachments.Add Msg, , 1 ' For some reasone position argument not working :(
'.Save
.Display
End With
End If
uj5u.com熱心網友回復:
.Display在編輯之前有一個 Outlook 怪癖。
看來它也適用于這種情況。
Option Explicit
Sub CreateTask()
Dim itm As Object
Dim msg As MailItem
Dim olTask As TaskItem
Set itm = ActiveExplorer.Selection.Item(1)
If itm.Class = olMail Then
Set msg = itm
Set olTask = CreateItem(olTaskItem)
With olTask
.subject = msg.subject
.RTFBody = msg.RTFBody
.Display ' <--- Earlier rather than later
.Attachments.Add msg, , 1
End With
End If
End Sub
uj5u.com熱心網友回復:
使用MailItem.MarkAsTask方法將MailItem物件標記為任務并為物件分配任務間隔。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/521990.html
標籤:vba外表
上一篇:VBA計數器忽略重復項
下一篇:如何使用vba洗掉重復的作業表?
