A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Script to delete duplcate messages in Outlook 2003



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 20th 06, 06:56 PM posted to microsoft.public.outlook.program_vba
David Sherman
external usenet poster
 
Posts: 26
Default Script to delete duplcate messages in Outlook 2003

Has anyone seen a VBS script that will remove duplicate messsages in
an Outllo 2003 *.pst file.

thanks
Ads
  #2  
Old February 21st 06, 06:21 AM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default Script to delete duplcate messages in Outlook 2003

Am Mon, 20 Feb 2006 13:56:39 -0500 schrieb David Sherman:

No VBS, but VBA. Maybe you can use it as a template for your own vbscript:
http://www.outlookcode.com/d/code/movemaildupes.htm

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Has anyone seen a VBS script that will remove duplicate messsages in
an Outllo 2003 *.pst file.

thanks

  #3  
Old February 21st 06, 03:39 PM posted to microsoft.public.outlook.program_vba
David Sherman
external usenet poster
 
Posts: 26
Default Script to delete duplcate messages in Outlook 2003

thanks for the link.




On Tue, 21 Feb 2006 07:21:42 +0100, Michael Bauer wrote:

Am Mon, 20 Feb 2006 13:56:39 -0500 schrieb David Sherman:

No VBS, but VBA. Maybe you can use it as a template for your own vbscript:
http://www.outlookcode.com/d/code/movemaildupes.htm


  #4  
Old February 21st 06, 04:59 PM posted to microsoft.public.outlook.program_vba
David Sherman
external usenet poster
 
Posts: 26
Default Script to delete duplcate messages in Outlook 2003

When I copy the code in Outlook, I get an Compile error- unexpected
end sub.

How do I fix this?

thanks

Sub NoMore()
' Code sample by Ulfar Erlingsson ]
' Moves duplicate items from the Inbox to a Dupes folder
' created under the Inbox

Private Sub MoveDuplicates()
Dim myDate As Date
Dim dupDate As Date
Dim mySubject As String
Dim dupSubject As String
Dim mySender As String
Dim dupSender As String
Dim myItems As Items
Dim myInbox As MAPIFolder
Dim myItem As Object
Dim dupItem As Object

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItems = myInbox.Items
On Error Resume Next
Set dupsFolder = myInbox.Folders("Dupes")
If Err 0 Then
Set dupsFolder = myInbox.Folders.Add("Dupes")
Err.Clear
End If

myItems.Sort "[Subject]", False
Set myItem = myItems.GetFirst
While TypeName(myItem) "Nothing"
If TypeName(myItem) = "MailItem" Then
myDate = myItem.ReceivedTime
mySubject = myItem.Subject
mySender = myItem.SenderName
If Err = 0 Then
Set dupItem = myItems.GetNext
dupDate = dupItem.CreationTime
If TypeName(dupItem) = "MailItem" Then
dupSubject = dupItem.Subject
dupSender = dupItem.SenderName
End If
If TypeName(dupItem) = "MailItem" _
And mySubject = dupItem.Subject _
And mySender = dupItem.SenderName _
And DateDiff("n", myDate, dupDate) 2 Then
dupItem.Move dupsFolder
Else
Set myItem = dupItem
End If
Else
Err.Clear
Set myItem = myItems.GetNext
End If
End If
Wend

Set myItem = Nothing
Set dupItem = Nothing
Set myItems = Nothing
Set myInbox = Nothing
Set myNameSpace = Nothing
Set myOlApp = Nothing
End Sub

End Sub



On Tue, 21 Feb 2006 07:21:42 +0100, Michael Bauer wrote:

Am Mon, 20 Feb 2006 13:56:39 -0500 schrieb David Sherman:

No VBS, but VBA. Maybe you can use it as a template for your own vbscript:
http://www.outlookcode.com/d/code/movemaildupes.htm

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Has anyone seen a VBS script that will remove duplicate messsages in
an Outllo 2003 *.pst file.

thanks


  #5  
Old February 21st 06, 05:42 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Script to delete duplcate messages in Outlook 2003

Take out the Sub NoMore declaration and extra End Sub statement. You can't declare one sub inside another.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"David Sherman" wrote in message ...
When I copy the code in Outlook, I get an Compile error- unexpected
end sub.

How do I fix this?

thanks

Sub NoMore()
' Code sample by Ulfar Erlingsson ]
' Moves duplicate items from the Inbox to a Dupes folder
' created under the Inbox

Private Sub MoveDuplicates()
Dim myDate As Date
Dim dupDate As Date
Dim mySubject As String
Dim dupSubject As String
Dim mySender As String
Dim dupSender As String
Dim myItems As Items
Dim myInbox As MAPIFolder
Dim myItem As Object
Dim dupItem As Object

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItems = myInbox.Items
On Error Resume Next
Set dupsFolder = myInbox.Folders("Dupes")
If Err 0 Then
Set dupsFolder = myInbox.Folders.Add("Dupes")
Err.Clear
End If

myItems.Sort "[Subject]", False
Set myItem = myItems.GetFirst
While TypeName(myItem) "Nothing"
If TypeName(myItem) = "MailItem" Then
myDate = myItem.ReceivedTime
mySubject = myItem.Subject
mySender = myItem.SenderName
If Err = 0 Then
Set dupItem = myItems.GetNext
dupDate = dupItem.CreationTime
If TypeName(dupItem) = "MailItem" Then
dupSubject = dupItem.Subject
dupSender = dupItem.SenderName
End If
If TypeName(dupItem) = "MailItem" _
And mySubject = dupItem.Subject _
And mySender = dupItem.SenderName _
And DateDiff("n", myDate, dupDate) 2 Then
dupItem.Move dupsFolder
Else
Set myItem = dupItem
End If
Else
Err.Clear
Set myItem = myItems.GetNext
End If
End If
Wend

Set myItem = Nothing
Set dupItem = Nothing
Set myItems = Nothing
Set myInbox = Nothing
Set myNameSpace = Nothing
Set myOlApp = Nothing
End Sub

End Sub



On Tue, 21 Feb 2006 07:21:42 +0100, Michael Bauer wrote:

Am Mon, 20 Feb 2006 13:56:39 -0500 schrieb David Sherman:

No VBS, but VBA. Maybe you can use it as a template for your own vbscript:
http://www.outlookcode.com/d/code/movemaildupes.htm

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Has anyone seen a VBS script that will remove duplicate messsages in
an Outllo 2003 *.pst file.

thanks


  #6  
Old February 21st 06, 06:20 PM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default Script to delete duplcate messages in Outlook 2003

Am Tue, 21 Feb 2006 11:59:12 -0500 schrieb David Sherman:

Please delete the outer Sub/End Sub.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


When I copy the code in Outlook, I get an Compile error- unexpected
end sub.

How do I fix this?

thanks

Sub NoMore()
' Code sample by Ulfar Erlingsson ]
' Moves duplicate items from the Inbox to a Dupes folder
' created under the Inbox

Private Sub MoveDuplicates()
Dim myDate As Date
Dim dupDate As Date
Dim mySubject As String
Dim dupSubject As String
Dim mySender As String
Dim dupSender As String
Dim myItems As Items
Dim myInbox As MAPIFolder
Dim myItem As Object
Dim dupItem As Object

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItems = myInbox.Items
On Error Resume Next
Set dupsFolder = myInbox.Folders("Dupes")
If Err 0 Then
Set dupsFolder = myInbox.Folders.Add("Dupes")
Err.Clear
End If

myItems.Sort "[Subject]", False
Set myItem = myItems.GetFirst
While TypeName(myItem) "Nothing"
If TypeName(myItem) = "MailItem" Then
myDate = myItem.ReceivedTime
mySubject = myItem.Subject
mySender = myItem.SenderName
If Err = 0 Then
Set dupItem = myItems.GetNext
dupDate = dupItem.CreationTime
If TypeName(dupItem) = "MailItem" Then
dupSubject = dupItem.Subject
dupSender = dupItem.SenderName
End If
If TypeName(dupItem) = "MailItem" _
And mySubject = dupItem.Subject _
And mySender = dupItem.SenderName _
And DateDiff("n", myDate, dupDate) 2 Then
dupItem.Move dupsFolder
Else
Set myItem = dupItem
End If
Else
Err.Clear
Set myItem = myItems.GetNext
End If
End If
Wend

Set myItem = Nothing
Set dupItem = Nothing
Set myItems = Nothing
Set myInbox = Nothing
Set myNameSpace = Nothing
Set myOlApp = Nothing
End Sub

End Sub



On Tue, 21 Feb 2006 07:21:42 +0100, Michael Bauer wrote:

Am Mon, 20 Feb 2006 13:56:39 -0500 schrieb David Sherman:

No VBS, but VBA. Maybe you can use it as a template for your own vbscript:
http://www.outlookcode.com/d/code/movemaildupes.htm

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Has anyone seen a VBS script that will remove duplicate messsages in
an Outllo 2003 *.pst file.

thanks

  #7  
Old February 21st 06, 06:49 PM posted to microsoft.public.outlook.program_vba
David Sherman
external usenet poster
 
Posts: 26
Default Script to delete duplcate messages in Outlook 2003

When I delete the following:

Sub NoMore()
' Code sample by Ulfar Erlingsson ]
' Moves duplicate items from the Inbox to a Dupes folder
' created under the Inbox

and the
End Sub, the macro doesn't show up.

When I deleted the word "private", the macro appears to run properly.

Thanks for the help.

On Tue, 21 Feb 2006 19:20:02 +0100, Michael Bauer wrote:

Am Tue, 21 Feb 2006 11:59:12 -0500 schrieb David Sherman:

Please delete the outer Sub/End Sub.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


When I copy the code in Outlook, I get an Compile error- unexpected
end sub.

How do I fix this?

thanks

Sub NoMore()
' Code sample by Ulfar Erlingsson ]
' Moves duplicate items from the Inbox to a Dupes folder
' created under the Inbox

Private Sub MoveDuplicates()
Dim myDate As Date
Dim dupDate As Date
Dim mySubject As String
Dim dupSubject As String
Dim mySender As String
Dim dupSender As String
Dim myItems As Items
Dim myInbox As MAPIFolder
Dim myItem As Object
Dim dupItem As Object

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItems = myInbox.Items
On Error Resume Next
Set dupsFolder = myInbox.Folders("Dupes")
If Err 0 Then
Set dupsFolder = myInbox.Folders.Add("Dupes")
Err.Clear
End If

myItems.Sort "[Subject]", False
Set myItem = myItems.GetFirst
While TypeName(myItem) "Nothing"
If TypeName(myItem) = "MailItem" Then
myDate = myItem.ReceivedTime
mySubject = myItem.Subject
mySender = myItem.SenderName
If Err = 0 Then
Set dupItem = myItems.GetNext
dupDate = dupItem.CreationTime
If TypeName(dupItem) = "MailItem" Then
dupSubject = dupItem.Subject
dupSender = dupItem.SenderName
End If
If TypeName(dupItem) = "MailItem" _
And mySubject = dupItem.Subject _
And mySender = dupItem.SenderName _
And DateDiff("n", myDate, dupDate) 2 Then
dupItem.Move dupsFolder
Else
Set myItem = dupItem
End If
Else
Err.Clear
Set myItem = myItems.GetNext
End If
End If
Wend

Set myItem = Nothing
Set dupItem = Nothing
Set myItems = Nothing
Set myInbox = Nothing
Set myNameSpace = Nothing
Set myOlApp = Nothing
End Sub

End Sub



On Tue, 21 Feb 2006 07:21:42 +0100, Michael Bauer wrote:

Am Mon, 20 Feb 2006 13:56:39 -0500 schrieb David Sherman:

No VBS, but VBA. Maybe you can use it as a template for your own vbscript:
http://www.outlookcode.com/d/code/movemaildupes.htm

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


Has anyone seen a VBS script that will remove duplicate messsages in
an Outllo 2003 *.pst file.

thanks


  #8  
Old February 21st 06, 07:02 PM posted to microsoft.public.outlook.program_vba
David Sherman
external usenet poster
 
Posts: 26
Default Script to delete duplcate messages in Outlook 2003 One Additional question

One Additional question:

When I run the script, I get a dialog box that says:

A program is trying to access e-mail addresses you have store in
Outlook. Do you want to allow this?

If I say yes, I get a time lime of up to 10 minutes.

How to I increase that time?

If I use 10 minutes, only 256 duplicates are found. I know that I have
over 8000 duplicate messages.

thanks

  #9  
Old February 21st 06, 07:23 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Script to delete duplcate messages in Outlook 2003 One Additional question

YOu can't increase the time. See http://www.outlookcode.com/d/sec.htm for your options with regard to the "object model guard" security in Outlook 2000 SP2 and later versions.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"David Sherman" wrote in message ...
One Additional question:

When I run the script, I get a dialog box that says:

A program is trying to access e-mail addresses you have store in
Outlook. Do you want to allow this?

If I say yes, I get a time lime of up to 10 minutes.

How to I increase that time?

If I use 10 minutes, only 256 duplicates are found. I know that I have
over 8000 duplicate messages.

thanks

  #10  
Old February 21st 06, 07:50 PM posted to microsoft.public.outlook.program_vba
David Sherman
external usenet poster
 
Posts: 26
Default Script to delete duplcate messages in Outlook 2003 One Additional question

Thanks for the information.

On Tue, 21 Feb 2006 14:23:47 -0500, "Sue Mosher [MVP-Outlook]"
wrote:

YOu can't increase the time. See http://www.outlookcode.com/d/sec.htm for your options with regard to the "object model guard" security in Outlook 2000 SP2 and later versions.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"David Sherman" wrote in message ...
One Additional question:

When I run the script, I get a dialog box that says:

A program is trying to access e-mail addresses you have store in
Outlook. Do you want to allow this?

If I say yes, I get a time lime of up to 10 minutes.

How to I increase that time?

If I use 10 minutes, only 256 duplicates are found. I know that I have
over 8000 duplicate messages.

thanks


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Action or Script to Purge Deleted Messages on IMAP account Frank M. Outlook and VBA 9 July 10th 09 06:44 PM
Script error when printing HTML messages Chris Rickman Outlook - Installation 8 April 17th 08 04:44 PM
How to send private messages with this script ON?? moony marouane Outlook - Using Forms 1 January 30th 06 10:31 AM
How to send private messages with this script ON?? moony marouane Outlook - General Queries 1 January 30th 06 10:30 AM
Outlook 2003 startup script error [email protected] Outlook - General Queries 0 January 24th 06 07:34 PM


All times are GMT +1. The time now is 10:47 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.