V
Vishal
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(olFolderDeletedItems).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
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(olFolderDeletedItems).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