Convert to Redemption ???


J

John DOE

Hi:

I have this OLD code (Access97) that I found on the net to open Outlook and
import emails into Access. I have 2003 and know about the security pop up.
I think that Redemption can get around this. If I install it, can anyone
help me converting this code? I have searched and searched for newer code,
but either way, the security pop up is still there and I can't find code
that will do what I have here.


Thanks

PS: This could all be very old, or even too old, so any ideas would greatly
be appreciated.

*******************************************************************
Private Sub Command3_Click()
'
Dim Olapp As Outlook.Application
Dim Olmapi As Outlook.NameSpace
Dim Olfolder As Outlook.MAPIFolder
Dim OlAccept As Outlook.MAPIFolder
Dim OlDecline As Outlook.MAPIFolder
Dim OlFailed As Outlook.MAPIFolder
Dim OlMail As Object ' Have to late bind as appointments e.t.c screw it up
Dim OlItems As Outlook.Items
Dim OlRecips As Outlook.Recipients
Dim OlRecip As Outlook.Recipient
Dim Rst As Recordset
'
Set Rst = CurrentDb.OpenRecordset("tblIBN-Hold")
Set Olapp = CreateObject("Outlook.Application")
Set Olmapi = Olapp.GetNamespace("MAPI")
Set Olfolder = Olmapi.GetDefaultFolder(olFolderInbox)
Set OlItems = Olfolder.Items
Set OlAccept = Olfolder.Folders("Passed")
Set OlFailed = Olfolder.Folders("Failed")
'
' Set up a loop to run till the inbox is empty (otherwise it skips some)
Do Until OlItems.Count = 0
'
Set OlItems = Olfolder.Items
For Each OlMail In OlItems
'
If OlMail.UnRead = True Then
OlMail.UnRead = False 'Mark mail as read
Rst.AddNew
Rst!IBNUser1 = OlMail.SenderName
'
If InStr(1, OlMail.Subject, "IBN") > 0 Then
Rst!IBNMember2 = OlMail.Subject
Rst!IBNDate = OlMail.ReceivedTime
Rst!IBNTime = OlMail.ReceivedTime
Rst!IBNBody = OlMail.Body
Rst!IBNHold = "True"
OlMail.Move OlAccept
Else
Rst!IBNMember2 = OlMail.Subject
Rst!IBNDate = OlMail.ReceivedTime
Rst!IBNTime = OlMail.ReceivedTime
Rst!IBNBody = OlMail.Body
Rst!IBNHold = "False"
OlMail.Move OlFailed
End If
'
Rst.Update
'
End If
'
Next
'
Loop
MsgBox "Your wish is my command. New mails have been checked. Please check
the tbl_temp for details", vbOKOnly
'
End Sub
 
Ad

Advertisements

D

Dmitry Streblechenko

Try something like the following (off the top of my head):

Private Sub Command3_Click()
'
Dim Olapp As Outlook.Application
Dim Olmapi As Outlook.NameSpace
Dim Olfolder As Outlook.MAPIFolder
Dim OlAccept As Outlook.MAPIFolder
Dim OlDecline As Outlook.MAPIFolder
Dim OlFailed As Outlook.MAPIFolder
Dim OlMail As Object ' Have to late bind as appointments e.t.c screw it up
Dim OlItems As Outlook.Items
Dim OlRecips As Outlook.Recipients
Dim OlRecip As Outlook.Recipient
Dim sItem as Object
Dim Rst As Recordset
'
Set Rst = CurrentDb.OpenRecordset("tblIBN-Hold")
Set Olapp = CreateObject("Outlook.Application")
Set Olmapi = Olapp.GetNamespace("MAPI")
Set Olfolder = Olmapi.GetDefaultFolder(olFolderInbox)
Set OlItems = Olfolder.Items
Set OlAccept = Olfolder.Folders("Passed")
Set OlFailed = Olfolder.Folders("Failed")
'
' Set up a loop to run till the inbox is empty (otherwise it skips some)
Do Until OlItems.Count = 0

set sItem = CreateObject("Redemption.SafeMailItem")

'
Set OlItems = Olfolder.Items
For Each OlMail In OlItems
'
If OlMail.UnRead = True Then
sItem.Item = OlMail
OlMail.UnRead = False 'Mark mail as read
Rst.AddNew
Rst!IBNUser1 = sItem.SenderName
'
If InStr(1, OlMail.Subject, "IBN") > 0 Then
Rst!IBNMember2 = OlMail.Subject
Rst!IBNDate = OlMail.ReceivedTime
Rst!IBNTime = OlMail.ReceivedTime
Rst!IBNBody = sItem.Body
Rst!IBNHold = "True"
OlMail.Move OlAccept
Else
Rst!IBNMember2 = OlMail.Subject
Rst!IBNDate = OlMail.ReceivedTime
Rst!IBNTime = OlMail.ReceivedTime
Rst!IBNBody = sItem.Body
Rst!IBNHold = "False"
OlMail.Move OlFailed
End If
'
Rst.Update
'
End If
'
Next
'
Loop
MsgBox "Your wish is my command. New mails have been checked. Please check
the tbl_temp for details", vbOKOnly
'
End Sub


Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top