Results 1 to 10 of 10

Thread: [Excel -> Outlook]

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2009
    Posts
    16

    [Excel -> Outlook]

    Hello,

    I have a macro written in VB in Excel, which reads emails from Outlook. I would like to automatize this process, but everytime, when Excel wants to access the outlook, I have to give permition to do that, see http://apophis.wz.cz/permition.PNG (It's in czech, but you will see the point). Is there any way to give this permition for ever? Or for long time, such as 10 hours? (I can choose max. 10 minutes).

    Thanks for every idea.


    Jakub Suchy
    Last edited by gaspaccho; Jul 19th, 2009 at 03:26 PM. Reason: I solved the previous problem

  2. #2
    Lively Member
    Join Date
    Aug 2008
    Posts
    100

    Re: [Excel -> Outlook]

    The security measures of Outlook are very annoying but most of them are for Office 2003 their to stay. In 2007 there are new possibilities.

    Can you tell us which part of your code fires this window?

  3. #3
    Addicted Member
    Join Date
    Jul 2009
    Posts
    208

    Re: [Excel -> Outlook]

    You could modify your VBA code to use Outlook Redemption objects, which bypass the security prompts.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jul 2009
    Posts
    16

    Re: [Excel -> Outlook]

    darbid: I have MS Office 2003 and part of code, which fires this window is (suprisly) this:

    SomeVariable = SubFolder.Items(i).Body

    His Nibbs: I will take a look.


    I've found maybe very useful article here: http://www.outlookcode.com/article.aspx?id=52 , but I'm little confused, because my english and skills aren't good enough and there are so many options ( I need access just for one specific .xls file and it's on in my work computer, so I can't install any other program...

    Thanks...

  5. #5
    Lively Member
    Join Date
    Aug 2008
    Posts
    100

    Re: [Excel -> Outlook]

    Yes that reference you sent is to a good site where you will get all the answers you want about Outlook.

    Are you sure that your code really fires the security window? In my experience the "body" of something should not.

    So could you please post all of your code starting with how you get the Outlook application "get object".

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [Excel -> Outlook]

    The Body property will indeed fire the security prompt as its a new secured property in Outlook 2003 and newer.
    See my FAQ on it for more - http://www.vbforums.com/showthread.php?t=402086

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jul 2009
    Posts
    16

    Re: [Excel -> Outlook]

    Hello again,

    I used Redemption (thanks for your help) and it works fine (I can read MailItem.Body,...) but I need to access my 2nd shared account in Outlook so I wrote something like this:
    Code:
     Set objRecipient = ns.CreateRecipient("My second account")
        With objRecipient
            .Resolve
            If .Resolved Then
                Set Inbox = ns.GetSharedDefaultFolder(objRecipient, olFolderInbox)
            End If
        End With
    Now the line ".Resolve" fires the security promt and I'm unable to rewrite it to "Redemption language". I've tried to surf their official site but with no success. Does anybody know what I have to write there? Or is there any other way to go to my 2nd account without ".Resolve"? Thanks for any thaughts,


    gaspaccho

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jul 2009
    Posts
    16

    Re: [Excel -> Outlook]

    Nobody knows?

  9. #9
    Lively Member
    Join Date
    Aug 2008
    Posts
    100

    Re: [Excel -> Outlook]

    Sorry I have not used Redemption and cannot help you with a specific answer.

    I also wanted to qualify my way of getting around the security measures OR how I avoid it. I had no idea what i was doing and it is by chance that I avoided it. This shows in my initial answer to you which was corrected.

    Like you I am using another program other than Outlook to read the emails. When I came up with this problem my first question was which email does the user want read?

    I solved this by creating a small macro (Outlook add-in) which created a button in outlook. When clicked it accepted the currently selected email as the email which the user wants to do something with.

    This outlook macro then sends (calls a function) the MailItem as an object to the other program (Excel or Access) and it is my experience that when you use this object eg MailItem.body in ( Excel or Access) I at least do not get the security measures. (Outlook 2003 SP3)

    You do not actually state how you "get your email" with excel but maybe the same method would work for you with recepients. Please note I have not tested it.

  10. #10
    Addicted Member
    Join Date
    Jul 2009
    Posts
    208

    Re: [Excel -> Outlook]

    How are you declaring the objRecipient variable?

    The normal way using Outlook objects is:

    Dim objRecipient As Outlook.Recipient

    But using Redemption it should be:

    Dim objRecipient As Redemption.SafeRecipient

    and then, maybe, you won't get the security prompt on the .Resolve line.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width