Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have one grid that grid I loaded Mai information from Exchange Server
using Below code

C#
Private Sub LoadInbox()
{


                ExchangeService _service = new ExchangeService(ExchangeVersion.Exchange2010);
                _service.Credentials = new WebCredentials("userName", "password");
                _service.AutodiscoverUrl("Email ID");
				
				
   FindItemsResults<Item> findResults = _service.FindItems(WellKnownFolderName.Inbox, view);;
   
 
					DataRow drrow;
                    if (findResults.Items.Count > 0)
                    {
                        dtInbox.Rows.Clear();
                        foreach (Item myItem in findResults.Items)
                        {
                            if (myItem is EmailMessage)
                            {
                                myItem.Load();

                                drrow = dtInbox.NewRow();
                                drrow["ID"] = (myItem as EmailMessage).Id;
                                drrow["Size"] = (myItem as EmailMessage).Size+ " kb";
                                drrow["Subject"] = (myItem as EmailMessage).Subject;
                                drrow["From"] = (myItem as EmailMessage).From;
                                drrow["ReceivedDate"] = (myItem as EmailMessage).DateTimeReceived;
                                drrow["Body"] = (myItem as EmailMessage).Body;

                                dtInbox.Rows.Add(drrow);

                            }
                        }
datagridview.datasource=dtInbox;

                    }
}





dtInbox data table

i binned to grid control

My requirement

When the user Click on gridview I will get Message Id

that means drrow["ID"] = (myItem as EmailMessage).Id

using that ID I Need to select Mail information From the Exchange Server

Example (subject,attachment,cc MailID Bc Mail ID etc.....)

How can i do this any one Help me.........
Posted
Updated 20-Jan-15 1:41am
v2

1 solution

C#
Item i = Item.Bind(_service, messageId);

if (i is EmailMessage)
{
         return (EmailMessage)i;
}


Then you can access the properties of the e-mail. This is because when using the FindItems() method you are getting only a small subset of the details available, so you need to go back to the service to get a specific message to get all the details.
 
Share this answer
 
v2
Comments
hebsiboy 20-Jan-15 9:46am    
hi bro

it is Working fine
same like i have Folder Id Based on that How can i find the Folder Contents
Wastedtalent 20-Jan-15 11:19am    
Exactly as you did above but with folder id:

FindItemsResults<item> findResults = _service.FindItems(folderID, view);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900