New to Outlook 2013, dealing with copying vs. moving sent items

Status
Not open for further replies.

outlook2013

Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server
New to Outlook 2013, first VBA code works, second one does not, can someone shed some light on this?

I am dealing with Moving Sent Items from Online Mailbox to PST\Sent Items:

Rule setup to “COPY” sent emails to BaseMailbox.pst\Sent Items

Inserted VBA code here to mark it as READ. This works fine but now I have the Sent Item in both Sent Items folders.

Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
Set Items = GetFolderPath("BaseMailbox\Sent Items").Items

End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
Item.UnRead = False
Item.Save

End Sub

Function GetFolderPath(ByVal FolderPath As String) As Outlook.Folder
Dim oFolder As Outlook.Folder
Dim FoldersArray As Variant
Dim i As Integer

On Error GoTo GetFolderPath_Error
If Left(FolderPath, 2) = "\\" Then
FolderPath = Right(FolderPath, Len(FolderPath) - 2)
End If
'Convert folderpath to array
FoldersArray = Split(FolderPath, "\")
Set oFolder = Application.Session.Folders.Item(FoldersArray(0))
If Not oFolder Is Nothing Then
For i = 1 To UBound(FoldersArray, 1)
Dim SubFolders As Outlook.Folders
Set SubFolders = oFolder.Folders
Set oFolder = SubFolders.Item(FoldersArray(i))
If oFolder Is Nothing Then
Set GetFolderPath = Nothing
End If
Next
End If
'Return the oFolder
Set GetFolderPath = oFolder
Exit Function


GetFolderPath_Error:
Set GetFolderPath = Nothing
Exit Function

End Function

So I’d rather move the Sent Item from online mailbox to BaseMailbox.pst\Sent Items instead of Copy, mark unread

So I Disabled Copy Send Items rule and changed the VBA code to this:

I get an error on running it at Item.Move MovePst

Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()

Set Items = Session.GetDefaultFolder(olFolderSentMail).Items

End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
Set MovePst = GetFolderPath("BaseMailbox\Sent Items")
Item.UnRead = False
Item.Move MovePst

End Sub

Function GetFolderPath(ByVal FolderPath As String) As Outlook.Folder
Dim oFolder As Outlook.Folder
Dim FoldersArray As Variant
Dim i As Integer

On Error GoTo GetFolderPath_Error
If Left(FolderPath, 2) = "\\" Then
FolderPath = Right(FolderPath, Len(FolderPath) - 2)
End If
'Convert folderpath to array
FoldersArray = Split(FolderPath, "\")
Set oFolder = Application.Session.Folders.Item(FoldersArray(0))
If Not oFolder Is Nothing Then
For i = 1 To UBound(FoldersArray, 1)
Dim SubFolders As Outlook.Folders
Set SubFolders = oFolder.Folders
Set oFolder = SubFolders.Item(FoldersArray(i))
If oFolder Is Nothing Then
Set GetFolderPath = Nothing
End If
Next
End If
'Return the oFolder
Set GetFolderPath = oFolder
Exit Function


GetFolderPath_Error:
Set GetFolderPath = Nothing
Exit Function

End Function
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
Paula S. Outlook 2013 won't recognize new password Using Outlook 4
B Outlook 2013 erratically deleting original file that is attached Using Outlook 0
X Using Outlook 2013 and Outlook 365 Using Outlook 1
I Error saving screenshots in a custom form in outlook 2016, outlook 365 - ok in outlook 2013, outlook 2010 Outlook VBA and Custom Forms 5
J Outlook 2013 Change color of text in data fields of contacts in Outlook 2013? Using Outlook 3
Commodore Outlook (2013) issues with icloud.com mail Using Outlook 0
D iCloud Add-in not working in Outlook 2013 and Outlook 2016 After Windows Upgrade & iCloud Upgrade Using Outlook 2
P Outlook 2013 "Item could not be moved - still an issue for Outlook 2013 Using Outlook 0
M Creating an RSS Feed **FROM** Outlook 2013 Calendar. Using Outlook 5
D Outlook 2013 Yahoo IMAP Sync problems Using Outlook 1
iwshim outlook 2013 - I cannot see the "Manage Add-ins" Using Outlook 2
B Outlook 2013/Exchange 2013 - Conf Rooms not fully booking "resolved conflict" meetings Using Outlook 3
G Can't create Folder Groups in Outlook 2013 Using Outlook 0
A Run time error 424. object required in outlook 2013 Outlook VBA and Custom Forms 10
Rupert Dragwater Several questions regarding Outlook 2013 Using Outlook 9
P Outlook 2013 opens with FILE tab selected. Using Outlook 3
I How to display sender's name instead of email address in outlook 2013 message Using Outlook 5
Z Outlook 2013 Gmail IMPA emails not showing dates only showing times Using Outlook 1
B Forward every other email in Outlook 2013 Outlook VBA and Custom Forms 2
P Synching Outlook 2013 Notes with iPhone 8 Using Outlook 1
N Outlook 2013 Folder View Using Outlook 8
M Outlook 2013 fails to start -- missing WindowsCodecs.dll error Using Outlook 3
David Michaels Contact card shows blank Outlook 2013 Outlook VBA and Custom Forms 0
J Calendar data can be viewed on Outlook.com, but no longer syncs to Outlook 2013 Using Outlook.com accounts in Outlook 3
C Attached files on Outlook 2010 Sp1 & Exc 2013 are missing Exchange Server Administration 1
R Folders shifting around in Outlook 2013 and 2016 Using Outlook 3
P Sync Desktop Outlook 2013 with Outlook.com? Using Outlook.com accounts in Outlook 5
J Outlook 2013 when clicking To in a new email show Company names Using Outlook 0
J Outlook - 2013 - Error msg when copying folders from Online Archives to another user's mailbox Using Outlook 0
D Outlook 2013 changing iCloud reminder time? Using Outlook 0
M OUTLOOK 2013 CONTACT PROPERTIES Using Outlook 0
J Object Variable or With Block Not Set Error in Outlook 2016 and not Outlook 2013 Outlook VBA and Custom Forms 3
P Outlook 2013 puts replies in Outbox Using Outlook 1
P Contacts gone missing in Outlook 2013 POP Using Outlook 4
M Outlook 2013 Using Outlook 1
P MS OUTLOOK 2013 - Adding Sender on the CC line Using Outlook 5
P MS OFFICE 2013 - Outlook locking up when using the sent on behalf of feature in VB Using Outlook 3
I Outlook 2010, 2013 will not open .msg or .eml files Using Outlook.com accounts in Outlook 1
Jeff Davis Help fix my Outlook 2013? Using Outlook 28
J Outlook 2013 hanging for unknown reason Using Outlook 1
O Outlook 2013 Problems sending large mails Using Outlook 4
K Rebuilding Outlook 2013 from Outlook.com after OS rebuild Using Outlook.com accounts in Outlook 2
O Windows 10 x64 Outlook 2013 - URL does not open (anymore) Using Outlook 3
J Will BCC messages still deliver if TO address fails Outlook 2013 Using Outlook 3
Liz Schneider PST from Outlook 2013 is now IMAP folders in 2016 Using Outlook 10
S Outlook 2013 doesn't download html messages Using Outlook 0
Gwarcyn Outlook 2013 / Address Books disappear Using Outlook 0
T Online Training for Outlook 2013 Using Outlook 0
Diane Poremsky Outlook 2013: Control Panel Mail Won't Open New Slipstick.com Articles 0
Diane Poremsky Outlook 2013 Notes have toolbars New Slipstick.com Articles 0
Similar threads


















































Top