Outlook Warning from VBA

Posted on 2011-10-26
Last Modified: 2012-05-12
I have automated a system to do auto emails when orders are being received in Access.  When it tries to auto download, I get this message.  The process needs to run at all times, and even in the night when someone can't "Allow".  How do I get around this message from Access code?
Question by:sharpapproach
    LVL 31

    Expert Comment

    This is the notorious Object Model Guardian, which fortunately has been removed from recent versions of Office.  To get around it, you can install and use the Redemption Library, available from this Website:  Here is some sample VBA code using Redemption objects instead of regular Outlook objects.  

    For more information on Redemption Libary, see my Access Archon article on the topic, which can be downloaded from this link:

    Alternatively, you can just upgrade to Office 2010, and this obnoxious security feature will go away.

    'Redemption objects and corresponding Outlook objects must
       'be declared as Object type
       Dim omsg As Object
       Dim msg As Object
       Dim otsk As Object
       Dim tsk As Object
          'Create new mail message and send it now
          Call OpenOutlook
          Set omsg = gappOutlook.CreateItem(olMailItem)
          Set msg = New Redemption.SafeMailItem
          msg.Item = omsg
          With msg
             .To = strToEMail
             .Subject = strMessageSubject
             .Body = strBody
          End With
          'Note:  Messages created with Redemption Library objects
          'are created in the Drafts folder instead of the Outbox,
          'but they will be sent as if from the Outbox.
          'Create task item for sending the mail message later
          Set otsk = gappOutlook.CreateItem(olTaskItem)
          Set tsk = New Redemption.SafeTaskItem
          strTaskMessage = "When the task reminder fires, an email message will " _
             & "be created and placed in the Drafts folder to be sent"
          With tsk
             .Item = otsk
             .Subject = strTaskSubject
             .DueDate = dteReminder
             .StartDate = dteReminder
             .Categories = "Reminder"
             .Body = strTaskMessage
             'Store info for mail message in unused Task fields
             .BillingInformation = strToEMail
             .CardData = strMessageSubject
             .Mileage = strBody
             'Set task reminder for date when message should be sent
             .ReminderSet = True
             .ReminderTime = dteReminder
             .Close (olSave)
          End With
       End If
          Set onitm = fldClientsStoreID.Items(1)
    	'There is no SafeNoteItem, but SafeMailItem can be used for note items
          Set nitm = New Redemption.SafeMailItem
          nitm.Item = onitm
          Set jitm = New Redemption.SafeJournalItem
          jitm.Item = ojitm

    Open in new window

    LVL 74

    Accepted Solution

    This will take care of that as well:

    LVL 74

    Expert Comment

    by:Jeffrey Coachman
    Note that there are many other Utilities that will do this with out referencing Outlook...

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
    Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

    732 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now