I have the below code in my "ThisOutlookSession" Object. As messages come into my Inbox, it automatically saves messages as an msg file to a server that meet the subject criteria. (I've modified for the example, so hopefully I didn't break anything modifying it). It works without any issues at all.
What I'm wondering, is there a way to perform the same function, except when sending a message? I just need certain types of messages saved as msg files...not all of them.
Code: Select all
Option Explicit
Public WithEvents itmsNewMessages As Outlook.Items
Private Sub Application_Startup()
Set itmsNewMessages = Outlook.Session.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub Application_Quit()
Set itmsNewMessages = Nothing
End Sub
Private Sub itmsNewMessages_ItemAdd(ByVal Item As Object)
With Item
If .Class = olMail Then
If .Subject Like "Message" & "*" Then
.SaveAs "\\server\path" & .msg:, olMSG
End If
End If
End With
End Sub