Link to home
Start Free TrialLog in
Avatar of TheChos
TheChos

asked on

Email body for Outlook region using VB.net

I've developed an Outlook Messagebox region and would like to be able to set one of my fields equal to the contents of the email being written.  Any direction on how to accomplish would be appreciated.

Thanks.
Avatar of Jesus Rodriguez
Jesus Rodriguez
Flag of United States of America image

Create an outlook addin Application and then do something like this

    Private Sub Application_NewMail() Handles Application.NewMail
        Dim tempApp As Outlook.Application
        Dim tempInbox As Outlook.MAPIFolder
        Dim InboxItems As Outlook.Items
        tempApp = CreateObject("Outlook.Application")
        tempInbox = tempApp.GetNamespace("Mapi").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
        InboxItems = tempInbox.Items
        Dim newMail As Outlook.MailItem

        Dim inBox As Outlook.MAPIFolder = Me.Application.ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
        Dim DestinationFolder As Outlook.MAPIFolder = inBox.Folders("Processed")
        For Each newMail In InboxItems
            Dim Des As String = newMail.Body
           'On Des variable you will have the body of the message for each new email that comes to the inbox
       Next

Open in new window

Avatar of TheChos
TheChos

ASKER

This doesn't reference the email that I currently have open.
ASKER CERTIFIED SOLUTION
Avatar of TheChos
TheChos

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TheChos

ASKER

Used Outlook.MailItem to determine the current email information.