Outlook 宏仅适用于一个帐户

Outlook 宏仅适用于一个帐户

我一直使用 Outlook 宏将所有草稿直接移动到发件箱:

 Sub SendAllDrafts()
' Send the messages in the Drafts folder (ignore any subfolders)
If MsgBox("Are you sure you want to send ALL the items in your default Drafts folder?", _
    vbQuestion + vbYesNo) <> vbYes Then Exit Sub
Dim fldDraft As MAPIFolder, msg As Outlook.MailItem, intCount As Integer
Set fldDraft = Outlook.GetNamespace("MAPI").GetDefaultFolder(olFolderDrafts)
intCount = 0
Do While fldDraft.Items.Count > 0
    Set msg = fldDraft.Items(1)
    msg.Send
    intCount = intCount + 1
Loop
If Not (msg Is Nothing) Then Set msg = Nothing
Set fldDraft = Nothing
MsgBox intCount & " messages sent", vbInformation + vbOKOnly
End Sub

宏在一个帐户上确实有效,但是当我切换到另一个帐户时,我收到一个错误:“运行时错误‘-2147467259 (80004005)’:Outlook 无法识别一个或多个名称。”当我按“调试”时,它会在“msg.Send”行上指向一个黄色箭头。打印屏幕

相关内容