![]() |
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
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 |