Results 1 to 4 of 4

Thread: Edit code with : Send , Date , Sub , Receiver in code below . Thanks

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Edit code with : Send , Date , Sub , Receiver in code below . Thanks

    Dear All .
    Please help me add : Send , Date , Sub , Receiver in code below . Thanks
    Private WithEvents InboxItems As Outlook.Items
    
    Sub Application_Startup()
        Dim xNameSpace As Outlook.NameSpace
        Set xNameSpace = Outlook.Application.Session
        Set InboxItems = xNameSpace.GetDefaultFolder(olFolderInbox).Items
    End Sub
    
    
    Private Sub InboxItems_ItemAdd(ByVal objItem As Object)
        Dim FSO
        Dim xMailItem As Outlook.MailItem
        Dim xFilePath As String
        Dim xRegEx
        Dim xFileName As String
        On Error Resume Next
        xFilePath = CreateObject("WScript.Shell").SpecialFolders(16)
        xFilePath = xFilePath & "\MyEmails"
        Set FSO = CreateObject("Scripting.FileSystemObject")
        If FSO.FolderExists(xFilePath) = False Then
            FSO.CreateFolder (xFilePath)
        End If
        Set xRegEx = CreateObject("vbscript.regexp")
        xRegEx.Global = True
        xRegEx.IgnoreCase = False
        xRegEx.Pattern = "\||\/|\<|\>|""|:|\*|\\|\?"
        If objItem.Class = olMail Then
            Set xMailItem = objItem
            xFileName = xRegEx.Replace(xMailItem.Subject, "")
            xMailItem.SaveAs xFilePath & "" & xFileName & ".msg", olMSG
        End If
        Exit Sub
    End Sub
    
    Last edited by Aussiebear; 07-08-2024 at 12:27 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •