Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   trying to copy an email (http://www.outlookbanter.com/outlook-vba/31953-trying-copy-email.html)

rub November 4th 06 02:50 AM

trying to copy an email
 
I am trying to select an email and then copy it. Then I want the Inbox
folder window to appear. I will select a folder and the copy of the
email will be put there. I can't get by the line "Set oFolderSelected
= oIns.Selection". Any ideas



Sub MoveEmail()
Dim oApp As Outlook.Application
Dim oExp As Outlook.Explorer
Dim oSelected As Outlook.Selection
Dim oFolderSelected As Outlook.Selection
Dim oItem As Outlook.MailItem
Dim oFldr As Outlook.Folders
Dim oNS As Outlook.NameSpace
'Dim oFldr As Outlook.MAPIFolder
Dim oBackup As Outlook.MAPIFolder

Dim intNumber As Integer
Dim intInspector As Integer

Set oApp = Outlook.Application
Set oExp = oApp.ActiveExplorer
Set oIns = oApp.ActiveInspector

Set oSelected = oExp.Selection


If oSelected.Count 1 Then GoTo exit_outofhere

Set oItem = oSelected.Item(oSelected.Count)
Set oNS = oApp.GetNamespace("MAPI")

oItem.Copy

Set oBackup = oNS.GetDefaultFolder(olFolderInbox)
oBackup.Display
Set oFolderSelected = oIns.Selection
If oFolderSelected.Count 1 Then GoTo exit_outofhere
oFolderSelected =
oNS.GetDefaultFolder(olFolderInbox).Folders.Item(o FolderSelected.Count)
oItem.Move oFolderSelected


exit_outofhe
Exit Sub
End Sub


Dmitry Streblechenko November 4th 06 05:17 AM

trying to copy an email
 
Selection is the property of the Explorer object, not Namespace:
Set oFolderSelected = oExp.Selection

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"rub" wrote in message
ups.com...
I am trying to select an email and then copy it. Then I want the Inbox
folder window to appear. I will select a folder and the copy of the
email will be put there. I can't get by the line "Set oFolderSelected
= oIns.Selection". Any ideas



Sub MoveEmail()
Dim oApp As Outlook.Application
Dim oExp As Outlook.Explorer
Dim oSelected As Outlook.Selection
Dim oFolderSelected As Outlook.Selection
Dim oItem As Outlook.MailItem
Dim oFldr As Outlook.Folders
Dim oNS As Outlook.NameSpace
'Dim oFldr As Outlook.MAPIFolder
Dim oBackup As Outlook.MAPIFolder

Dim intNumber As Integer
Dim intInspector As Integer

Set oApp = Outlook.Application
Set oExp = oApp.ActiveExplorer
Set oIns = oApp.ActiveInspector

Set oSelected = oExp.Selection


If oSelected.Count 1 Then GoTo exit_outofhere

Set oItem = oSelected.Item(oSelected.Count)
Set oNS = oApp.GetNamespace("MAPI")

oItem.Copy

Set oBackup = oNS.GetDefaultFolder(olFolderInbox)
oBackup.Display
Set oFolderSelected = oIns.Selection
If oFolderSelected.Count 1 Then GoTo exit_outofhere
oFolderSelected =
oNS.GetDefaultFolder(olFolderInbox).Folders.Item(o FolderSelected.Count)
oItem.Move oFolderSelected


exit_outofhe
Exit Sub
End Sub




rub November 5th 06 10:21 PM

trying to copy an email
 

Thank you.

Dmitry Streblechenko wrote:
Selection is the property of the Explorer object, not Namespace:
Set oFolderSelected = oExp.Selection

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"rub" wrote in message
ups.com...
I am trying to select an email and then copy it. Then I want the Inbox
folder window to appear. I will select a folder and the copy of the
email will be put there. I can't get by the line "Set oFolderSelected
= oIns.Selection". Any ideas



Sub MoveEmail()
Dim oApp As Outlook.Application
Dim oExp As Outlook.Explorer
Dim oSelected As Outlook.Selection
Dim oFolderSelected As Outlook.Selection
Dim oItem As Outlook.MailItem
Dim oFldr As Outlook.Folders
Dim oNS As Outlook.NameSpace
'Dim oFldr As Outlook.MAPIFolder
Dim oBackup As Outlook.MAPIFolder

Dim intNumber As Integer
Dim intInspector As Integer

Set oApp = Outlook.Application
Set oExp = oApp.ActiveExplorer
Set oIns = oApp.ActiveInspector

Set oSelected = oExp.Selection


If oSelected.Count 1 Then GoTo exit_outofhere

Set oItem = oSelected.Item(oSelected.Count)
Set oNS = oApp.GetNamespace("MAPI")

oItem.Copy

Set oBackup = oNS.GetDefaultFolder(olFolderInbox)
oBackup.Display
Set oFolderSelected = oIns.Selection
If oFolderSelected.Count 1 Then GoTo exit_outofhere
oFolderSelected =
oNS.GetDefaultFolder(olFolderInbox).Folders.Item(o FolderSelected.Count)
oItem.Move oFolderSelected


exit_outofhe
Exit Sub
End Sub




All times are GMT +1. The time now is 05:54 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com