![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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) |
Ads |
#2
|
|||
|
|||
![]()
You cannot move an embedded message (that's what MSG filee really) directly
using the Outlook Object Model. You can save it first, then call Application.CreateItemFromTemplate specifying the path to the MSG file. Just keep in mind that CreateItemFromTemplate will strip out all the sender related properties; the new message will be created in an unsent state in teh Drafts folder (you can call MailItem.Move later to move it to a different fodler though). plugYou can use Redemption (url below) to import an MSG file - create a new item in the target folder and just call SafeMailItem/RDOMail.Importplug Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "IncJourn" wrote in message ... 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) |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How do I see the full line of a msg (inbox), without moving side | Singa | Outlook - General Queries | 1 | July 11th 06 04:00 PM |
Moving Folder | Denis R Charron | Outlook - General Queries | 0 | June 27th 06 06:33 PM |
Drag msg to explorer folder - change name? | ben ik | Outlook - General Queries | 1 | April 13th 06 12:20 AM |
"Unable to Display the Folder" msg, can't delete folder | Yvonne | Outlook - Calandaring | 2 | March 29th 06 09:01 PM |
How to copy attachment .msg into folder ? | [email protected] | Outlook and VBA | 2 | February 22nd 06 02:17 PM |