Moving .msg attachment to inbox

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)
 
J

JulieS

Hi Phil,

You've posted your message to a newsgroup focused on Microsoft Project, a
project management scheduling tool.

I suggest re-posting your message to a newsgroup for the email program
(Outlook?) you are using. If you are using Outlook, I believe there is a
newsgroup called Outlook Programming - VBA.

I hope this helps.

Julie

Visit http://project.mvps.org/ for the FAQs and additional information about
Microsoft Project
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top