Using outlook.application in Foxpro

Posted on 2010-01-07
Last Modified: 2012-06-27
I came across this neat little program for usng Outlook via Foxpro.  It works well, and most of my clients have Outlook anyway, but whenever I run it I get a warning, I assume from Outlook, that some program (mine!!) is accessing Outlook and I have to choose if I allow or cancel the operation.  I want to just send it and forget it.  Any idea how to do this?

And, any idea if other programs like Eudora, etc. can be accessed the same way.  Outlook Express is NOT supposed to work with this:


oOutLookObject = CreateObject("Outlook.Application")
oEmailItem = oOutLookObject.CreateItem(MAILITEM)

WITH oEmailItem
   .Recipients.Add("") && uses the Recipients collection
   .Subject = "Automation sample"
   .Body = "This is easy!"
   .Attachments.Add("c:\mydir\sample.txt") && Note that the fully qualified path and file is required.

RELEASE oEmailItem
RELEASE oOutLookObject
Question by:fmoore0001

    Expert Comment

    Hello, I have a client who runs a mail exchange 2003 for sending your emails
    it tells me that this problem only happens with me. your emails will be queued and reintanta your shipping up to 3 hours. reach the end sent to my mail, but after 50 attempts. are small post. my email is a lotus notes and I happened to anyone else. I have a fireward Junipper and review it and which has no restriction.
    the error that customer brand the connection was dropped by the remote host

    sgs previously had a 5400, which changed the thinking that this could be the problem but we continue with the same

    we reviewed all our dns, telnet've tested and both tests are successful in my business, so I guess the problem is with my client. thinking that he needs some adjustment to their exchange, the glue used to barracuda

    could someone help me with this detail
    se los agradeceria much because I have almost four months
    LVL 12

    Assisted Solution

    The warning message is one of the many 'features' thrust upon you by Micro$oft as the result of an Outlook Update.  It came in one of the Service Packs (probably SP-2).

    I have heard that you can change the Outlook Security settings to get rid of it, but I never found out where/how to do it.   Perhaps someone can point out the particulars on how to change Outlook to eliminate the Warning Message.   It would fix your issue for free.

    Regardless, long before I was even aware of the possibility of changing Outlook's settings I chose to use a 3rd party tool to get around this annoying issue.
    I use Redemption  (  
    It isn't free, but it works well to eliminate the issue totally and the support from the creator Dmitry has been very good.  Additionally through Redemption I have introduced some functionality that I think would have been very difficult to do directly through Outlook.

    Another 3rd party tool that you might look into would be ClickYes (   It works by stuffing the keyboard buffer to fool Outlook that the YES button has been clicked in the Warning message window.

    Good Luck


    Author Comment


    My problem is I have thousands of clients, so either program is no an option, unless I could add them as a DLL to my software.  Anyone else have an idea how to turn off the security from Foxpro or maybe buffer the yes response from Foxpro?


    Author Comment

    Another alternative is to use the MAILTO command, but I found no way to make it send automatically.

    Author Comment

    Oh, my.  Now I did the following in Outlook 2007:

    I tried running Outlook .exe as a administrator
    I set the Programmatic Access Security to: Never warn me about suspicious activity
    Tried running my test program.  Would not even try to e-mail this time.  Kept getting errors
    Closed that outlook session and restarted my normal outlook session.
    The Programmatic Access Security reset to: Warn me about suspicious activity when my antivirus...
    Oh, well.
    Then I ran my test program one last time.  Now, it sends with no warnings at all!!  I can find NOTHING reset in outlook, and have no idea what the hell I did.
    I reboot the computer.  Still lets me send with no problems.

    Any ideas from anyone?  What did I do?

    Microsoft, oh Microsoft, why dost thou persecute thy programmers!!
    LVL 29

    Expert Comment

    by:Olaf Doschke
    Those settings of Outlook are in the registry, see
    In OL2007 this should still work the same. In company environments with an Exchange server, these security settings may not work and you need to ask the Exchange adminitrator to configure this centrally for all outlook clients.

    Most probably the actions you took as admin created those or very similar registry entries to allow OL automation in general. Disadvantage is, you opened the gate for every program automating outlook email.

    And then there is another tool simply programmatically confirming the dialogs warning about automation of outlook, google redemption. and this has the same disadvantage.

    On the other side spam mail bots will usually simply provide their own ways of sending mails, not via oulook, but directly by a tcp port and with the smtp protocol, so it's not much of a risc to allow automation of outlook. Then again you take away control over it, if you perforate that security.

    I think it really was a good idea of MS to listen to customer wishes to raise security and it's a bad sign, that this has still not become standard knowledge of developers and instead hacks like redemption became popular.

    Bye, Olaf.

    Author Comment


    I disagree on the security issue as this "security" has made the Office Automation of Outlook, well, worthless.  As you have said most spam bots take their own way to send e-mails, and Microsoft's security in this case just made a legitimate use of it worthless.  This is not a win for users or programmers.

    With that kind of thinking, the current administrations Homeland Security ought been be recuiting from Microsoft's developer pool.

    Okay, assume the Office Automation portion of Outlook is now worthless.  Anybody have some alternatives for e-mailing from Foxpro where I can automatic the process, such as confirming to an investor that a payment has been made his account whenever the payment is processed?

    LVL 14

    Expert Comment

    If you run Outlook as Administrator, then you will have to run your program as administrator too, otherwise the createobject will fail.

    You have most probably saved the "Never warn me about suspicious activity" so there is no warning any longer.
    LVL 29

    Expert Comment

    by:Olaf Doschke

    I already pointed you towards the solution.

    And it's not Microsofts job to a make every  home secure, that spam bots could send mail through. But they go forward and make their #1 mail client a thing, of which the users remains in control.

    In in regard to the other security holes, Microsoft just holds back, because they don't want to push anti-virus and firewall manufacturers out of business. They couldn't afford the bad publicity that would make. I'm sure they could do the best protection suite, even if they'd need to buy some patent license. Who else but the manufacurer of an OS can protect it best.

    They did a really good job with Vista's security, they did not so well with OneCare and the standard antispyware tool "Windows Defender", but the windows firewall is pretty good usable and as I already said I assume they don't retreat from this area because they lack knowledge.

    You're proving to be ignorant, if you still ask for a solution, when you're already given one. Sorry to say that.
    If you want an easier way than setting up some registry keys, I can also give you the google search result, here you are:

    And ask for a refund and deletion of this question. This is not worth of being put into the EE KB and it's already in there in many sections anyway.

    RE DEMP TION. memorize it.

    Bye, Olaf.
    LVL 29

    Expert Comment

    by:Olaf Doschke
    ps: Let me apologize for the tone, Frank, but not for the core statements. You best try to find the registry keys corresponding to OL2007, if they really differ and solve it that cleaner way.

    Bye, Olaf.

    Author Comment


    I was very surprised at the tone, especially when you have been so helpful in the past.  Your answer and solution were insufficent, and not what I was looking for at all.

    I have written to the redemption people twice with no response.   I was hoping to hear some other solutions if possible.  You may not know everything on the market.  Thank you.


    LVL 29

    Accepted Solution


    again my apaology for my tone.

    And besides that, I'm very sure redemption is solving your problem. You will need to rewrite the code a little, if you use redemption, because then you're using redemption objects and redemption is controlling outlook via Extended Mapi:

    There's a vfp sample code on how to use redemption over there at foxite:

    Besides that there are even more than the usual 3 ways to send mail from vfp, and this has also already been discussed and pointed to many many times - sigh.

    Bye, Olaf.
    LOCAL loOutlook   AS Outlook.Application
    LOCAL loNameSpace AS Outlook.NameSpace 
    LOCAL loMailItem  AS Outlook.MailItem
    LOCAL loSafeItem  AS Object 
    #DEFINE olMailItem   0
    loOutlook   = CREATEOBJECT('Outlook.Application')
    loNameSpace = loOutlook.GetNamespace("MAPI")
    loMailItem  = loOutlook.CreateItem( olMailItem )   && This creates the MailItem Object
    loSafeItem  = CREATEOBJECT(Redemption.SafeMailItem)
    WITH loSafeItem
        .Item    = loMailItem     && This attaches the Mail Object to 
                                  && Redemption SafeMailItem Object
        .Subject = "Test Email with VFP & Redemption"
        .Body    = "This is the Main Body of the Message"
        .Send   && this does not cause the Security Dialog to be displayed.

    Open in new window


    Author Closing Comment

    Thanks for all the suggestion, as always.

    Expert Comment

    you could also try this freeware program out it allows you to selectively allow access to outlook (and bypass security) by specific application.

    Expert Comment

    I just did a project where I needed to create a PDF file and email it without the user seeing any interaction in Outlook 2003. This is the link to the library. I have the code the works for sure with his library if anyone wants it, let me know. No security message...,guid,baccc84d-4d91-458b-a839-ad03662dfc34.aspx

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: (http://msd…
    Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    746 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