By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,589 Members | 1,017 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,589 IT Pros & Developers. It's quick & easy.

Outlook Redemption

100+
P: 157
Hello!

Is there someone where who can givme a code example on a Outlook innbox import ta a table in Access using Outlook redemption ?

This is a little bit out-of-my-league programming :)
May 21 '07 #1
Share this Question
Share on Google+
6 Replies

100+
P: 157
Please anyone.

I have to get this inbox import working so that i can start desgning the rest of the system.

Now i have surfed around on the web 2 days and tried and tried a million approaches but it just refuses to import my mails to a table..

Kindly Regards a frustrated Eirik
May 22 '07 #2

100+
P: 157
Like this:
Expand|Select|Wrap|Line Numbers
  1. Dim SafeMailItem, oMailItem
  2. Set SafeMailItem = CreateObject("Redemption.SafeMailItem")
  3. Set oMailItem = Outlook.Session.GetDefaultFolder(10).Items(1)
  4. SafeMailItem.Item = oMailItem
  5. MsgBox SafeMailItem.SenderName 
Should retur me the mail sendername

But it gives me a empty msgbox
May 22 '07 #3

100+
P: 157
And this code
Expand|Select|Wrap|Line Numbers
  1. dim utils, MailItem, PrSenderEmailAddress, SenderEMail
  2. set utils = CreateObject("Redemption.MAPIUtils")
  3. set MailItem = Application.Session.GetDefaultFolder(6).Items(1)  'Get the first item in the inbox, can be any other item
  4. PrSenderEmailAddress = &H0C1F001E
  5. SenderEMail = utils.HrGetOneProp(MailItem.MAPIOBJECT, PrSenderEmailAddress)
  6. MsgBox SenderEMail 
  7.  
Gives me a mark on the Session in Application.Session.GetDefaultFolder(6).Items(1) with a msg of "method or data member not found"

and when i add this as instructed on the web page
Expand|Select|Wrap|Line Numbers
  1. set Application = CreateObject("Outlook.Application")
  2. set Namespace = Application.GetNamespace("MAPI")
  3. Namespace.Logon
  4.  
It gives me the same msg but this time on the GetNameSpace in the Application.GetNamespace("MAPI")
May 22 '07 #4

100+
P: 157
Forget it. I just found out that if i change "Application" to "Outlook" it works!!!
Whooa!! Now i can send mails from VBA without the stupid warning message and 5 second wait


But still not figured out how to import inbox into table
May 22 '07 #5

100+
P: 157
I am so proud

Expand|Select|Wrap|Line Numbers
  1. Dim rSt As New ADODB.Recordset
  2. Dim MailImport As Object, oMailImport As Object
  3. Dim mottatt As String
  4.  
  5. For i = 1 To 200
  6.  
  7. Set oMailImport = Outlook.Session.GetDefaultFolder(olFolderInbox).Items(i)
  8. Set MailImport = New Redemption.SafeMailItem
  9.  
  10. MailImport.Item = oMailImport
  11.  
  12. mottatt = MailImport.ReceivedTime
  13.  
  14. If IsNull(DLookup("date", "tbl emails", "Date = '" & mottatt & "'")) Then
  15. rSt.Open "[tbl emails]", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
  16.         With rSt
  17.             .AddNew
  18.             ![Date] = MailImport.ReceivedTime
  19.             ![fra] = MailImport.Sendername
  20.             ![emne] = MailImport.Subject
  21.             ![Body] = MailImport.Body
  22.             .Update
  23.         End With
  24.     rSt.Close
  25.     Set rSt = Nothing
  26. End If
  27.  
  28. Next
May 22 '07 #6

ADezii
Expert 5K+
P: 8,750
I am so proud

Expand|Select|Wrap|Line Numbers
  1. Dim rSt As New ADODB.Recordset
  2. Dim MailImport As Object, oMailImport As Object
  3. Dim mottatt As String
  4.  
  5. For i = 1 To 200
  6.  
  7. Set oMailImport = Outlook.Session.GetDefaultFolder(olFolderInbox).Items(i)
  8. Set MailImport = New Redemption.SafeMailItem
  9.  
  10. MailImport.Item = oMailImport
  11.  
  12. mottatt = MailImport.ReceivedTime
  13.  
  14. If IsNull(DLookup("date", "tbl emails", "Date = '" & mottatt & "'")) Then
  15. rSt.Open "[tbl emails]", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
  16.         With rSt
  17.             .AddNew
  18.             ![Date] = MailImport.ReceivedTime
  19.             ![fra] = MailImport.Sendername
  20.             ![emne] = MailImport.Subject
  21.             ![Body] = MailImport.Body
  22.             .Update
  23.         End With
  24.     rSt.Close
  25.     Set rSt = Nothing
  26. End If
  27.  
  28. Next
GHood for you, MrDeej!
May 22 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.