Solved

Email Body

Posted on 2016-09-08
4
90 Views
Last Modified: 2016-10-12
I have been asked to extract the mail from an outlook account problematically.

I have go so far but what I am getting is the entire email's trail.  Is there a means to get this information.

 
private void btnAddToSupportCall_Click(Office.CommandBarButton ctrl, ref bool cancel)
{
    string delimeter = "x###x";
    var emailAddress = this.Application.ActiveExplorer().Session.CurrentUser.AddressEntry.GetExchangeUser().PrimarySmtpAddress;

    Outlook.MailItem mailItem = Inspector.CurrentItem as Outlook.MailItem;
    string str = mailItem.SenderName + delimeter + mailItem.SenderEmailAddress + delimeter + mailItem.Subject + delimeter + mailItem.Body + delimeter + mailItem.ReceivedTime.Date.ToShortDateString() + delimeter + mailItem.ReceivedTime.ToShortTimeString();
    new FormAddEmailToSupportCall(str, delimeter, emailAddress).ShowDialog();
}

Open in new window

0
Comment
Question by:Alyanto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 35

Expert Comment

by:Kimputer
ID: 41789602
Hard to read what you actually mean.
Do you mean you want the internet headers of that email?
0
 
LVL 1

Author Comment

by:Alyanto
ID: 41791043
Hi Kimputer
To clarify one of my colleagues asked me for a favour and then I used a spell checked without checking.  The the original should read.

I have been asked to extract the mail from an outlook account programmatically.

I have go so far but what I am getting is the entire email's trail.  Is there a means to get this information.  

I spoke to her again and what she wanted was to connect to an exchange server under a specific account and extract on arrival the last part of an email's chain.  The code above is what was sent to me  by her.  I am hoping some has done this sort of thing before and has a bit of stock code they could share.

Kind regards

Alyanto
0
 
LVL 35

Accepted Solution

by:
Kimputer earned 500 total points
ID: 41791234
It's what I thought. Here's code for not the last part, but the full header (which obviously contains the last part).
Since she or you are probably more C# savvy, I only have the VB code. Please translate it to C# yourself.

private void btnAddToSupportCall_Click(Office.CommandBarButton ctrl, ref bool cancel)
{
    string delimeter = "x###x";
    var emailAddress = this.Application.ActiveExplorer().Session.CurrentUser.AddressEntry.GetExchangeUser().PrimarySmtpAddress;

    Outlook.MailItem mailItem = Inspector.CurrentItem as Outlook.MailItem;
	
	'.net Visual Basic code
	Const PR_TRANSPORT_MESSAGE_HEADERS = "http://schemas.microsoft.com/mapi/proptag/0x007D001E"
    Dim olkPA As Outlook.PropertyAccessor
    Set olkPA = mailItem.PropertyAccessor
    FullInetHeaders = olkPA.GetProperty(PR_TRANSPORT_MESSAGE_HEADERS)
    Set olkPA = Nothing
	' end .net Visual Basic code
	
    string str = FullInetHeaders + delimeter +  mailItem.SenderName + delimeter + mailItem.SenderEmailAddress + delimeter + mailItem.Subject + delimeter + mailItem.Body + delimeter + mailItem.ReceivedTime.Date.ToShortDateString() + delimeter + mailItem.ReceivedTime.ToShortTimeString();
    new FormAddEmailToSupportCall(str, delimeter, emailAddress).ShowDialog();
}

Open in new window

0
 
LVL 1

Author Closing Comment

by:Alyanto
ID: 41840073
I finally got an answer from our junior and he has been able to move the problem based on the ideas here.
0

Featured Post

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Mailbox Overload?
In-place Upgrading Dirsync to Azure AD Connect
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

724 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