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

Outlook Macro to delete email from Sent Folder and Delete Folder



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 23rd 07, 04:39 PM posted to microsoft.public.outlook.program_vba
Vishal
external usenet poster
 
Posts: 3
Default Outlook Macro to delete email from Sent Folder and Delete Folder

Hi,

I have a macro given by someone which deletes a mail sent to a particular id
from Sent Folder and then permanently deletes it from the Delete Folder as
well. It was working fine earlier but now it doesn't ! When I run it says :

Compile error: Expected: end of statement

Please advise.

Thanks in advance,
-V

Macro
----------------------------------------------------------

VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "ThisOutlookSession"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Public WithEvents mySentItems As Outlook.Items
Attribute mySentItems.VB_VarHelpID = -1
Public WithEvents myDeletedItems As Outlook.Items
Attribute myDeletedItems.VB_VarHelpID = -1


Public Sub Application_Startup()

Set mySentItems = Outlook.Session.GetDefaultFolder(olFolderSentMail) .Items
Set myDeletedItems =
Outlook.Session.GetDefaultFolder(olFolderDeletedIt ems).Items

End Sub

Private Sub mySentItems_ItemAdd(ByVal Item As Object)
Dim OutgoingMail As Outlook.MailItem
Dim SentTo As String

Set OutgoingMail = Item
SentTo = OutgoingMail.To
Debug.Print Time
Debug.Print SentTo
If SentTo = "IMG POC P2P SFEG ID" Then
OutgoingMail.Delete
End If

End Sub
Private Sub myDeletedItems_ItemAdd(ByVal Item As Object)
Dim OutgoingMail As Outlook.MailItem
Dim SentTo As String

Set OutgoingMail = Item
SentTo = OutgoingMail.To
Debug.Print Time
Debug.Print SentTo
If SentTo = "IMG POC P2P SFEG ID" Then
OutgoingMail.Delete
End If

End Sub




  #2  
Old February 23rd 07, 06:56 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Outlook Macro to delete email from Sent Folder and Delete Folder

Could you point out which code statement raises that error, please?

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

"Vishal" wrote in message ...
Hi,

I have a macro given by someone which deletes a mail sent to a particular id
from Sent Folder and then permanently deletes it from the Delete Folder as
well. It was working fine earlier but now it doesn't ! When I run it says :

Compile error: Expected: end of statement

Please advise.

Thanks in advance,
-V

Macro
----------------------------------------------------------

VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "ThisOutlookSession"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Public WithEvents mySentItems As Outlook.Items
Attribute mySentItems.VB_VarHelpID = -1
Public WithEvents myDeletedItems As Outlook.Items
Attribute myDeletedItems.VB_VarHelpID = -1


Public Sub Application_Startup()

Set mySentItems = Outlook.Session.GetDefaultFolder(olFolderSentMail) .Items
Set myDeletedItems =
Outlook.Session.GetDefaultFolder(olFolderDeletedIt ems).Items

End Sub

Private Sub mySentItems_ItemAdd(ByVal Item As Object)
Dim OutgoingMail As Outlook.MailItem
Dim SentTo As String

Set OutgoingMail = Item
SentTo = OutgoingMail.To
Debug.Print Time
Debug.Print SentTo
If SentTo = "IMG POC P2P SFEG ID" Then
OutgoingMail.Delete
End If

End Sub
Private Sub myDeletedItems_ItemAdd(ByVal Item As Object)
Dim OutgoingMail As Outlook.MailItem
Dim SentTo As String

Set OutgoingMail = Item
SentTo = OutgoingMail.To
Debug.Print Time
Debug.Print SentTo
If SentTo = "IMG POC P2P SFEG ID" Then
OutgoingMail.Delete
End If

End Sub




  #3  
Old February 23rd 07, 07:24 PM posted to microsoft.public.outlook.program_vba
Vishal
external usenet poster
 
Posts: 3
Default Outlook Macro to delete email from Sent Folder and Delete Fold

Hi Sue,

Thanks for offering help. It gives error at the very first statement on
CLASS:
VERSION 1.0 CLASS

Following statement as well as all the Attribute statements are highlighted
in red - Syntax error.

BEGIN
MultiUse = -1 'True
End

Thanks,
-V


"Sue Mosher [MVP-Outlook]" wrote:

Could you point out which code statement raises that error, please?

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

"Vishal" wrote in message ...
Hi,

I have a macro given by someone which deletes a mail sent to a particular id
from Sent Folder and then permanently deletes it from the Delete Folder as
well. It was working fine earlier but now it doesn't ! When I run it says :

Compile error: Expected: end of statement

Please advise.

Thanks in advance,
-V

Macro
----------------------------------------------------------

VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "ThisOutlookSession"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Public WithEvents mySentItems As Outlook.Items
Attribute mySentItems.VB_VarHelpID = -1
Public WithEvents myDeletedItems As Outlook.Items
Attribute myDeletedItems.VB_VarHelpID = -1


Public Sub Application_Startup()

Set mySentItems = Outlook.Session.GetDefaultFolder(olFolderSentMail) .Items
Set myDeletedItems =
Outlook.Session.GetDefaultFolder(olFolderDeletedIt ems).Items

End Sub

Private Sub mySentItems_ItemAdd(ByVal Item As Object)
Dim OutgoingMail As Outlook.MailItem
Dim SentTo As String

Set OutgoingMail = Item
SentTo = OutgoingMail.To
Debug.Print Time
Debug.Print SentTo
If SentTo = "IMG POC P2P SFEG ID" Then
OutgoingMail.Delete
End If

End Sub
Private Sub myDeletedItems_ItemAdd(ByVal Item As Object)
Dim OutgoingMail As Outlook.MailItem
Dim SentTo As String

Set OutgoingMail = Item
SentTo = OutgoingMail.To
Debug.Print Time
Debug.Print SentTo
If SentTo = "IMG POC P2P SFEG ID" Then
OutgoingMail.Delete
End If

End Sub





  #4  
Old February 24th 07, 04:52 AM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Outlook Macro to delete email from Sent Folder and Delete Fold

I don't know why you're seeing those statements in VBA, but then again, we don't know what the other person actually gave you or what you did with it. The usable code begins at the first Public Public WithEvents statement.

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

"Vishal" wrote in message ...
Hi Sue,

Thanks for offering help. It gives error at the very first statement on
CLASS:
VERSION 1.0 CLASS

Following statement as well as all the Attribute statements are highlighted
in red - Syntax error.

BEGIN
MultiUse = -1 'True
End

Thanks,
-V


"Sue Mosher [MVP-Outlook]" wrote:

Could you point out which code statement raises that error, please?

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

"Vishal" wrote in message ...
Hi,

I have a macro given by someone which deletes a mail sent to a particular id
from Sent Folder and then permanently deletes it from the Delete Folder as
well. It was working fine earlier but now it doesn't ! When I run it says :

Compile error: Expected: end of statement

Please advise.

Thanks in advance,
-V

Macro
----------------------------------------------------------

VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "ThisOutlookSession"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Public WithEvents mySentItems As Outlook.Items
Attribute mySentItems.VB_VarHelpID = -1
Public WithEvents myDeletedItems As Outlook.Items
Attribute myDeletedItems.VB_VarHelpID = -1


Public Sub Application_Startup()

Set mySentItems = Outlook.Session.GetDefaultFolder(olFolderSentMail) .Items
Set myDeletedItems =
Outlook.Session.GetDefaultFolder(olFolderDeletedIt ems).Items

End Sub

Private Sub mySentItems_ItemAdd(ByVal Item As Object)
Dim OutgoingMail As Outlook.MailItem
Dim SentTo As String

Set OutgoingMail = Item
SentTo = OutgoingMail.To
Debug.Print Time
Debug.Print SentTo
If SentTo = "IMG POC P2P SFEG ID" Then
OutgoingMail.Delete
End If

End Sub
Private Sub myDeletedItems_ItemAdd(ByVal Item As Object)
Dim OutgoingMail As Outlook.MailItem
Dim SentTo As String

Set OutgoingMail = Item
SentTo = OutgoingMail.To
Debug.Print Time
Debug.Print SentTo
If SentTo = "IMG POC P2P SFEG ID" Then
OutgoingMail.Delete
End If

End Sub





 




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
Any way to delete an item stuck in Outlook Drafts folder? Joe3Eagles Outlook - Using Contacts 1 October 9th 06 09:48 AM
How can I delete duplicates in my Outlook 2003 contacts folder? Don Smith Outlook - General Queries 2 October 6th 06 03:12 AM
"Unable to Display the Folder" msg, can't delete folder Yvonne Outlook - Calandaring 2 March 29th 06 08:01 PM
Junk E-mail folder - is there a way to create a rule to delete items in this folder older than X days? Jaycee Outlook - General Queries 1 February 22nd 06 04:54 PM
Why I Cannot delete Journal folder from Outlook 2003 ? niladri chatterjee Outlook - Installation 1 February 13th 06 12:06 PM


All times are GMT +1. The time now is 05:05 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-2025 Outlook Banter.
The comments are property of their posters.