M
m|sf|t
All,
Below is some code that I am working on that adds the email address of the
selected items to our GFI blacklist. The code works perfect, except for
these lines:
Set objDel = objApp.Session.GetItemFromID(strEntryID)
objDel.Delete
which is where I am attempting to delete the item from the deleted items
folder.
I probably goobered it up a bunch, it's my first real attempt at an Outlook
addon.
Dim objApp As Outlook.Application
Dim objSelection As Selection
Dim objExplorer As Object
Dim objItem As Object
Dim objDel As Object
Dim db As Database
Dim strSQL As String
Dim strDomain As String
Dim strEmail As String
Dim strEntryID As String
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Set objApp = CreateObject("Outlook.Application")
Msg = "Process these email(s) as SPAM ?"
Style = vbYesNo + vbCritical + vbDefaultButton2
Title = "Anti-Spam"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
Set db = DBEngine.Workspaces(0).OpenDatabase("\\svr\c$\Program
Files\GFI\MailEssentials\config.mdb")
Dim oExp As Outlook.Explorer
Set oExp = Outlook.ActiveExplorer
Set objSelection = oExp.Selection
If objSelection.Count > 0 Then
For Each objItem In objSelection
If TypeOf objItem Is MailItem Then
strEmail = R_GetSenderAddress(objItem)
If Not (strEmail Like "*domain1.com") Or (strEmail Like
"*domain2.com") Then
strSQL = "INSERT INTO antispam2_blacklist
(entry,type) VALUES ('" & strEmail & "','1')"
db.Execute strSQL
strEntryID = objItem.entryID
objItem.Delete
Set objDel =
objApp.Session.GetItemFromID(strEntryID)
objDel.Delete
End If
End If
Next
End If
db.Close
End If
Set objApp = Nothing
Set objSelection = Nothing
Set objItem = Nothing
Thanks everyone.
Below is some code that I am working on that adds the email address of the
selected items to our GFI blacklist. The code works perfect, except for
these lines:
Set objDel = objApp.Session.GetItemFromID(strEntryID)
objDel.Delete
which is where I am attempting to delete the item from the deleted items
folder.
I probably goobered it up a bunch, it's my first real attempt at an Outlook
addon.
Dim objApp As Outlook.Application
Dim objSelection As Selection
Dim objExplorer As Object
Dim objItem As Object
Dim objDel As Object
Dim db As Database
Dim strSQL As String
Dim strDomain As String
Dim strEmail As String
Dim strEntryID As String
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Set objApp = CreateObject("Outlook.Application")
Msg = "Process these email(s) as SPAM ?"
Style = vbYesNo + vbCritical + vbDefaultButton2
Title = "Anti-Spam"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
Set db = DBEngine.Workspaces(0).OpenDatabase("\\svr\c$\Program
Files\GFI\MailEssentials\config.mdb")
Dim oExp As Outlook.Explorer
Set oExp = Outlook.ActiveExplorer
Set objSelection = oExp.Selection
If objSelection.Count > 0 Then
For Each objItem In objSelection
If TypeOf objItem Is MailItem Then
strEmail = R_GetSenderAddress(objItem)
If Not (strEmail Like "*domain1.com") Or (strEmail Like
"*domain2.com") Then
strSQL = "INSERT INTO antispam2_blacklist
(entry,type) VALUES ('" & strEmail & "','1')"
db.Execute strSQL
strEntryID = objItem.entryID
objItem.Delete
Set objDel =
objApp.Session.GetItemFromID(strEntryID)
objDel.Delete
End If
End If
Next
End If
db.Close
End If
Set objApp = Nothing
Set objSelection = Nothing
Set objItem = Nothing
Thanks everyone.