vbscript VBScript将已发送的项目移动到Outlook中的收件箱

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript VBScript将已发送的项目移动到Outlook中的收件箱相关的知识,希望对你有一定的参考价值。

Function GetFolderPath(ByVal FolderPath As String) As Outlook.Folder

    Dim oFolder As Outlook.Folder
    Dim FoldersArray As Variant
    Dim i As Integer
    
    On Error GoTo GetFolderPath_Error
    
    If Left(FolderPath, 2) = "\\" Then
        FolderPath = Right(FolderPath, Len(FolderPath) - 2)
    End If
    
    'Convert folderpath to array
    FoldersArray = Split(FolderPath, "\")
    Set oFolder = Application.Session.Folders.Item(FoldersArray(0))
    
    If Not oFolder Is Nothing Then
        
        For i = 1 To UBound(FoldersArray, 1)
        
            Dim SubFolders As Outlook.Folders
            Set SubFolders = oFolder.Folders
            Set oFolder = SubFolders.Item(FoldersArray(i))
            
            If oFolder Is Nothing Then
                Set GetFolderPath = Nothing
            End If
    
        Next
    End If
    
    'Return the oFolder
    Set GetFolderPath = oFolder
    
Exit Function
    
GetFolderPath_Error:
    Set GetFolderPath = Nothing
    Exit Function
End Function


Private Sub Application_Startup()
    Set SentItems = Outlook.Session.GetDefaultFolder(olFolderSentMail).Items
    Set SentItems2 = GetFolderPath("name@account2.com\Sent Items").Items
End Sub

Private Sub Application_Quit()
    Set SentItems = Nothing
    Set SentItems2 = Nothing
End Sub

Private Sub SentItems_ItemAdd(ByVal Item As Object)
    Item.UnRead = False
    Item.Move Outlook.Session.GetDefaultFolder(olFolderInbox)
End Sub

 Private Sub SentItems2_ItemAdd(ByVal Item As Object)
    Item.UnRead = False
    Item.Move GetFolderPath("name@account2.com\Inbox")
End Sub

以上是关于vbscript VBScript将已发送的项目移动到Outlook中的收件箱的主要内容,如果未能解决你的问题,请参考以下文章

Batch-VBScript 发送特定键的特定次数[关闭]

vbscript 从表格发送电子邮件

在 vbscript 中发送多部分电子邮件

vbscript 从Excel发送电子邮件 - VBA

vbscript 用于使用Remedy内容发送电子邮件

混合 Batch-VBScript 文件中的发送键