Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete mail from SMTP Mailbox

Status
Not open for further replies.

carlp69

IS-IT--Management
Sep 23, 2003
157
GB
I basically want to know if this is possible.

If I have an Access Database that posts requests for leave into a single mailbox on an Exchange 2000 server and give authorised personel access to the mailbox. Each request contains a link back to the database to approve or reject the particular request. I make a part of the subject line unique (i.e "Request - " + Idno of the request).

Once the link has been clicked and the leave processed, is there any way of deleting / disabling the email to avoid multiple processing of requests by other authorised users.

Either by VBA or Redemption?
 
Do you have outlook as email client?

If so, you can use code similar to:

Code:
Function MoveMail(MyMapiFolder As MAPIFolder) As Boolean
On Error GoTo Error_Handler
MoveMail = True

Dim iNumEmails, i As Integer
Dim strSearchString, strSearchChar, strChrPos, strBaseMessage As String
Dim MyFolder As Outlook.MAPIFolder
Dim MailItem As Outlook.MailItem
Dim objItems As Outlook.Items
Dim error_mail As String

loop1:
Set MyFolder = MyMapiFolder
Set objItems = MyFolder.Items

iNumEmails = objItems.Count
   If iNumEmails <> 0 Then
      For i = 1 To iNumEmails
         If TypeName(objItems(i)) = "MailItem" Then
            Set MailItem = objItems(i)
            [COLOR=red]MailItem.Delete
            MailItem.Move [/color]
CurrentMailBox.Folders("afgehandeld") 
            GoTo loop1 
         End If
      Next i
    End If

Exit_Handler:
    Exit Function

Error_Handler:
    MoveMail = False
    Call LogError("MoveMail", CurrentUser(), "MoveEmail " & Err.Number & " " & Err.Description & " " & error_mail)
    Resume Next

End Function

Here I use mailitem.move, but you can also use mailitem.delete.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top