I
IncJourn
All,
I have the following code to detect a email that has a .msg attachment. I
want to move the .msg attachment into my inbox and delete the parent message.
I cannot move the attachment using the .move method. Can I redefine Atmt as
an object in or should I save the .msg and import it. I don't know how to do
either and I'd appriciate any assistance.
Sub MoveMSGAttachment()
Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim SubFolder As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
Dim varResponse As VbMsgBoxResult
Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
i = 0
For Each Item In Inbox.Items
For Each Atmt In Item.Attachments
If Right(Atmt.FileName, 3) = "msg" Then
'FileName = "C:\temp\" & Atmt.FileName 'Not required
'Atmt.SaveAsFile FileName 'Not required
Atmt.Move Inbox ' *** PROBLEM CODE ***
Item.Delete
i = i + 1
End If
Next Atmt
Next Item
End Sub
Thanks and regards
Phil (IncJourn)
I have the following code to detect a email that has a .msg attachment. I
want to move the .msg attachment into my inbox and delete the parent message.
I cannot move the attachment using the .move method. Can I redefine Atmt as
an object in or should I save the .msg and import it. I don't know how to do
either and I'd appriciate any assistance.
Sub MoveMSGAttachment()
Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim SubFolder As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
Dim varResponse As VbMsgBoxResult
Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
i = 0
For Each Item In Inbox.Items
For Each Atmt In Item.Attachments
If Right(Atmt.FileName, 3) = "msg" Then
'FileName = "C:\temp\" & Atmt.FileName 'Not required
'Atmt.SaveAsFile FileName 'Not required
Atmt.Move Inbox ' *** PROBLEM CODE ***
Item.Delete
i = i + 1
End If
Next Atmt
Next Item
End Sub
Thanks and regards
Phil (IncJourn)