Results 1 to 11 of 11

Thread: Using VB-NET with Outlook 2003

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2004
    Location
    NAIROBI, kenya
    Posts
    1

    Using VB-NET with Outlook 2003

    I'm trying to use VB-net 7.0 to retrieve emails from my MS Outlook 2003 inbox, and store the To, Subject and Message to different fields in the ms sql 2000 database.

    Help!

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Post in the VB.NET forum!

    A few people there have worked with Office objects and would be able to help you.

  3. #3

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

    Here is a small demo I wrote for you to show how to acccess the
    Outlook default Inbox.

    VB Code:
    1. 'Add a reference to MS Outlook xx.0 Object Library
    2. 'Project > Add Reference... > COM tab > select MS Outlook 11.0 Object library
    3. Public Class Form1
    4.  
    5.     Inherits System.Windows.Forms.Form
    6.  
    7.     Public moApp As Outlook.Application
    8.     Public moNS As Outlook.NameSpace
    9.  
    10.     '"Windows Form Designer generated code"
    11.  
    12.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    13.         Dim oFolder As Outlook.MAPIFolder
    14.         Dim oEmail As Outlook.MailItem
    15.  
    16.         oFolder = moNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
    17.         If oFolder.Items.Count > 0 Then
    18.             oEmail = oFolder.Items.Item(1)
    19.             MessageBox.Show(oEmail.Subject, ".NET Outlook Demo", MessageBoxButtons.OK, MessageBoxIcon.Information)
    20.         Else
    21.             MessageBox.Show("No items found!", ".NET Outlook Demo", MessageBoxButtons.OK, MessageBoxIcon.Information)
    22.         End If
    23.         oEmail = Nothing
    24.         oFolder = Nothing
    25.  
    26.     End Sub
    27.  
    28.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    29.         moApp = New Outlook.Application
    30.         moNS = moApp.GetNamespace("MAPI")
    31.     End Sub
    32.  
    33. End Class
    Last edited by RobDog888; Nov 21st, 2004 at 01:15 AM.
    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

  5. #5
    New Member
    Join Date
    Nov 2004
    Posts
    8

    Re: Using VB-NET with Outlook 2003

    Hi Guys,
    Will this code take care of the securty warning messages?
    Right now I have a application which uses MAPI controls (MAPISession, MAPIMesages) to connect to outlook 2000. We are going to upgrade it to outlook 2003.

    Pls. suggest me a quick solution other than redemption and changing security settings on exchage server.

    Thanks for all your help.

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

    Re: Using VB-NET with Outlook 2003

    No, my code will not by pass the Security Prompt. To get around the Security Prompt
    you need to create an Outlook Add-In and use the passed in Application
    object throughout your Add-In so it will remain trusted.

    HTH
    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
    New Member
    Join Date
    Nov 2004
    Posts
    8

    Re: Using VB-NET with Outlook 2003

    Hi Rob,
    Thanks for your reply. Can I create a outlook add-in and use it in existing application (code) or do I need to rewrite the entire code?
    In my application, I am setting the username of MAPISession to a mail profile and using MAPIMessages control to perform other operations. I am not using any outlook object.
    So what can I do to avoid the security warnings still using the MAPI controls instead of outlook object?

    I am new to this concept.
    Thanks for your help.

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

    Re: Using VB-NET with Outlook 2003

    You can probably use most of your code but you need to OnConnection
    procedure, etc. receiving the trusted application object in its parameter or it
    will still get the popup.

    If you dont want to use Outlook, you can use SMTP as long as you have
    access to a SMTP server. This is the only other way that I know of that will
    bypass the popup when sending emails.

    HTH
    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

  9. #9
    New Member
    Join Date
    Nov 2004
    Posts
    8

    Re: Using VB-NET with Outlook 2003

    Rob,
    Could you please provide some sample code for OnConnection procedure and Could you please explain how I can use this withe MAPI methods?

    Thanks.

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

    Re: Using VB-NET with Outlook 2003

    You can make an Add-In for Outlook using .NET only VB6 for now. Not
    even with VSTO 2003/2005. They still have not included Outlook in any of
    their current development programs. So I guess for an Add-In you need
    to use VB6?
    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

  11. #11
    New Member
    Join Date
    Mar 2005
    Posts
    5

    Re: Using VB-NET with Outlook 2003

    please, can u write an example of how to write the onConnect event such that I can bypass the security popup? or give me links to some resources about this subject.

    this's exactly my problem>>

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