locked
Getting Info from Outlook RRS feed

  • Question

  • I am looking for a way with VB .NET to get the full contents of an email when its opened with outlook.  I want the full headers and source if possible.

    Thursday, January 31, 2008 5:50 PM

Answers

  • Hi Ryan,

     

    Try these codes: (I write the sample in VB.NET winform)

    Code Snippet

    Imports Office = Microsoft.Office.Core
    Imports Outlook = Microsoft.Office.Interop.Outlook
    Imports System.Runtime.InteropServices


    Public Class Form1
        Dim WithEvents app As Outlook.Application
        Dim WithEvents inspectors As Outlook.Inspectors

        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            app = Marshal.GetActiveObject("Outlook.Application")
            inspectors = app.Inspectors
        End Sub

        Private Sub Inspectors_New(ByVal inspector As Outlook.Inspector) Handles inspectors.NewInspector
            Dim mail As Outlook.MailItem = inspector.CurrentItem
            MessageBox.Show(mail.Subject)
            MessageBox.Show(mail.To)
            MessageBox.Show(mail.Body)
        End Sub

    End Class

     

     

     

     

    Thanks

    Ji

     

    Monday, February 4, 2008 3:23 AM