Solved

Email Body

Posted on 2016-09-08
4
66 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
  • 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
In this video we show how to create a mailbox database in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Servers >> Data…
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…

810 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