Solved

Scanning inbox brings up Outlook security message

Posted on 2011-03-24
6
357 Views
Last Modified: 2012-05-11
I have an Access database that needs to scan through a inbox subfolder to read the "SenderEmailAddress" information.  After a lot of good help (and persistence) from BlueDevilFan, we ended up with the following code, which worked a treat.  However, it comes up with the Outlook Security message, which I need to get rid of.

Originally we linked into email sub-folders through ADO, which looked ideal - but the ADO object does not present the "SenderEmailAddress".

Unfortunately, we cannot use any third party products for this fix - so any suggestions would be greatly appreciated.
Sub ReadBounced()

    Dim olkApp As Object, olkSes As Object, olkFld As Object, olkMsg As Object
    Set olkApp = CreateObject("Outlook.Application")
    Set olkSes = olkApp.GetNamespace("MAPI")    
    olkSes.Logon
    Set olkFld = olkSes.GetDefaultFolder(6).Folders("00 Technical").Folders("Bounced emails")
    For Each olkMsg In olkFld.Items
        With olkMsg
            Debug.Print .SenderEmailAddress
        End With
    Next
    Set olkMsg = Nothing
    Set olkFld = Nothing
    olkSes.Logoff
    Set olkSes = Nothing
    Set olkApp = Nothing
    
End Sub

Open in new window

0
Comment
Question by:Andy Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 20

Assisted Solution

by:darbid73
darbid73 earned 200 total points
ID: 35205532
I think one of the best resources of information about Outlook / books / Your Security Question is Outlook Code - here

Now there are many many different solutions to this problem and I do not intend to list them all. You are obviously aware of 3rd party ones as well which you have ruled out.

Once you understand why you get the security prompt you will understand my next statements:

If you get your outlook object from Outlook itself when outlook starts and you then use this object for any code, you will not get a security prompt.  To put that in paractical terms, if you take your code - remove the CreateObject - and put it into Outlook itself then you will not get the prompts.

Thus my suggestion is that you let us know more about your structure of communication between Access and outlook and if you for example have to distribute this to lots of people or not.  I am heading toward you making an addon or something like that yourself or just coding in Outlook if distribution is not a problem.  Outlook code can commuicate with Access code and vica-versa - and Outlook can also write directly to your database with DAO or ADO if you want.
0
 

Author Comment

by:Andy Brown
ID: 35205558
Thank you for that very useful response - makes a lot of sense (especially the add-on route).  I'm going to take a closer look at that first and then see where we are.

Thanks again.

0
 
LVL 20

Expert Comment

by:darbid73
ID: 35205612
The addon route is a nightmare.  I am still trying to understand it with Visual Studio and .NET.  If you can find a Visula Basic 6 version laying around I am better at making a COM addon from it. Although this is a really old way of doing things these days.

In my opinion your first step is what code can you move over to Outlook.  Outlook has a VBeditor too and you can code there as well.  Once you get the code working how you like then you can look at the distribution issue.  If it is only a couple of computers then you could just add the code to their computer, but if it major then you have to look at addons again.

I am sure BDF will be along with suggestions as well.
0
Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 

Author Comment

by:Andy Brown
ID: 35205622
Thank you - due to the number of machines running this, I think an Add-on is the way to go, but I am still looking into it.
0
 
LVL 10

Accepted Solution

by:
conagraman earned 300 total points
ID: 35217330
this is what i use

'------needs a reference to Microsoft Outlook 12.0 object library
On Error Resume Next

Dim Olook As Outlook.Application
Dim oNs As Outlook.NameSpace
Dim oFldr As Outlook.MAPIFolder
Dim OMail As Outlook.MailItem
Dim LookFor As String

Set Olook = New Outlook.Application
Set oNs = Olook.GetNamespace("MAPI")
Set oFldr = oNs.GetDefaultFolder(olFolderInbox)   '/////////////  mailbox

For Each OMail In oFldr.Items
        With OMail
       
           MsgBox (.SenderEmailAddress)  '//////////do something

        End With
Next OMail
         
    Set OMail = Nothing
    Set oFldr = Nothing
    Set oNs = Nothing
    Set Olook = Nothing
0
 

Author Closing Comment

by:Andy Brown
ID: 35217369
Thanks guys - that's really good information.

All the best.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…
Suggested Courses

634 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question