Hello,
this is a crossed post from:
https://www.excelforum.com/outlook-...-move-processed-e-mail-to-another-folder.html
There is no reply so maybe here i will find the answer.
I would like to ask you about my macro.
Macro is working very good - saving all atachments from new e-mails in folder "FolderTest" and next macro is moving processed e-mail to folder "processed".
My macro code:
I am wondering why saving is working only once. When I am reciving e-mail and moving it to folder "FolderTest" macro is working fine (attachments are saved and e-mail is moved to "processed" folder.
Problem is when i am returning e-mail to inbox at all and try to move it once again to "FolderTest".
Macro is running normally, even e-mail is moved to folder "processed" but attachments are not saved...
Why this is working like that?
Please Help,
Jacek Antek
this is a crossed post from:
https://www.excelforum.com/outlook-...-move-processed-e-mail-to-another-folder.html
There is no reply so maybe here i will find the answer.
I would like to ask you about my macro.
Macro is working very good - saving all atachments from new e-mails in folder "FolderTest" and next macro is moving processed e-mail to folder "processed".
My macro code:
Code:
Public WithEvents FolderItems As Outlook.Items
Private Sub Application_Startup()
Set FolderItems = Session.GetDefaultFolder(olFolderInbox).Folders("FolderTest").Items
End Sub
Private Sub FolderItems_ItemAdd(ByVal Item As Object)
On Error Resume Next
Dim oAttachment As Outlook.Attachment
Dim sSaveFolder As String
Dim myDestFolder As Outlook.Folder
Set myDestFolder = Outlook.Session.GetDefaultFolder(olFolderInbox).Folders("FolderTest").Folders("processed")
sSaveFolder = "C:\temp"
For Each oAttachment In Item.Attachments
If oAttachment.DisplayName Like "*.doc" Then
oAttachment.SaveAsFile sSaveFolder & oAttachment.DisplayName
End If
Next
Item.Move myDestFolder
End Sub
I am wondering why saving is working only once. When I am reciving e-mail and moving it to folder "FolderTest" macro is working fine (attachments are saved and e-mail is moved to "processed" folder.
Problem is when i am returning e-mail to inbox at all and try to move it once again to "FolderTest".
Macro is running normally, even e-mail is moved to folder "processed" but attachments are not saved...
Why this is working like that?
Please Help,
Jacek Antek
Last edited: