namespace: using Microsoft.Exchange.WebServices.Data
dll: c:\Program Files (x86)\Microsoft\Exchange\Web Services\2.1\Microsoft.Exchange.WebServices.dll
And is it possible to write multiple functions in the code stage? : Not sure,
Previous code is implemented in studio, Modified code as per code stage which you can just copy and paste and use the action:
DataTable table = new DataTable();
table.Columns.AddRange(new DataColumn[] { new DataColumn(""Item ID"", Type.GetType(""System.String"")),
new DataColumn(""Sender"", Type.GetType(""System.String"")),
new DataColumn(""Subject"", Type.GetType(""System.String"")),
new DataColumn(""CC"", Type.GetType(""System.String"")),
new DataColumn(""TO"", Type.GetType(""System.String"")),
new DataColumn(""Body"", Type.GetType(""System.String"")),
new DataColumn(""DateReceived"", Type.GetType(""System.String""))});
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
service.Credentials = new NetworkCredential(Username, Password);
service.Url = new Uri(ServiceURL);
Mailbox mb = new Mailbox(EmailID);
FolderId fid1 = new FolderId(WellKnownFolderName.Inbox, mb);
PropertySet itempropertyset = new PropertySet(BasePropertySet.FirstClassProperties);
itempropertyset.RequestedBodyType = BodyType.Text;
ItemView itemview = new ItemView(1000);
itemview.PropertySet = itempropertyset;
FindItemsResults findResults = service.FindItems(fid1, new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, ReadAllMails)), new ItemView(1000));
service.LoadPropertiesForItems(findResults, PropertySet.FirstClassProperties);
foreach (Item item in findResults.Items)
{
EmailMessage mes = (EmailMessage)item;
ItemId itemID = item.Id;
item.Load(itempropertyset);
DataRow row = table.NewRow();
row[""Subject""] = item.Subject;
row[""Sender""] = mes.Sender.Name;
row[""CC""] = String.Join("","", mes.CcRecipients);
row[""TO""] = String.Join("","", mes.ToRecipients); ;
// row[""Sender Address""] = mes.From.Address;
row[""Body""] = item.Body.Text;
row[""Item ID""] = itemID;
// row[""Attachment""] = (item.HasAttachments) ? ""True"" : ""false"";
// row[""DateReceived""] = mes.DateTimeReceived;
table.Rows.Add(row);
}
Create output variable of code stage named collection_out
finally, collection_out = table
In the code i have done the bold text, wherever you find that should be input to code stage.
Thank you.