Using the code examples provided by Independentsoft:
PropertyName myPropertyName = new PropertyName("Disabled", StandardPropertySet.PublicStrings, MapiPropertyType.String);
Exists restrictionExists = new Exists(myPropertyName);
response = service.FindItem(StandardFolder.Inbox, MessagePropertyPath.AllPropertyPaths, new Not(restrictionExists));
we are getting the message but the BodyHtmlText is null...
Using Exchange Server 2010 SP2.
Anyone had any problems with this?
FindItems doesn't return the body (and a number of other properties) you need to make a GetItem Request on the Item in question to get these properties see https://msdn.microsoft.com/en-us/library/bb508824.aspx
Related
I'm developing an application that tracks exchange email messages in our company.
We where able to get info out from the tracking log, but in the log -by design- there is no subject or body message.
So the next step for us was using EWS to get the message detail when needed.
The question is that in the tracking log we find to IDs :
MessageId in format "F533E7F015A2E24F8D8ABFE2587117C601EDF245#blstex02.subdomain.domain.com"
and
InternalMessageId in format "5840818"
If in EWS we use this id to find the message by id we always get an "Id is malformed." exception.
Here is the code we use:
public static EmailMessage GetEmailById(string uNameToImpersonate, string StringItemId)
{
return EmailMessage.Bind(GetService(uNameToImpersonate), new ItemId(StringItemId));
}
I'm a newbie to EWS so maybe I'm missing something really easy...
Thanks for your help
You can only bind to a Message using the EWSId see https://msdn.microsoft.com/en-us/library/office/dn605828(v=exchg.150).aspx for a more detailed discussion.For the InternetId you will need to search for messages with that particular Id using the findItem operation eg something like
ItemView ivew = new ItemView(1);
service.TraceEnabled = true;
ExtendedPropertyDefinition PidTagInternetMessageId = new ExtendedPropertyDefinition(4149, MapiPropertyType.String);
SearchFilter sf = new SearchFilter.IsEqualTo(PidTagInternetMessageId, "F533E7F015A2E24F8D8ABFE2587117C601EDF245#blstex02.subdomain.domain.com");
FindItemsResults<Item> iCol = service.FindItems(WellKnownFolderName.Inbox, sf, ivew);
foreach (Item item in iCol.Items)
{
Console.WriteLine(item.Subject);
}
in a Windows 10 UWP I try use WebAuthenticationCoreManager.RequestTokenAsync to get the result from a login with a Microsoft account.
I get a WebTokenRequestResult with Success. ResponseData[0] contains a WebAccount with an ID - but the UserName is empty.
The scope of the call is wl.basic - so I should get a lot of information...
I'm not sure how to retrieve extra information - and for the current test the Username would be OK.
I checked out the universal samples - and there I found a snippet which tries to do what I'm trying - an output of webTokenRequestResult.ResponseData[0].WebAccount.UserName.
By the way - the example output is also empty.
Is this a bug - or what do I (and the MS in the samples) have to do to get the users profile data (or at least the Username)?
According to the documentation (https://learn.microsoft.com/en-us/windows/uwp/security/web-account-manager), you have to make a specific REST API call to retrieve it:
var restApi = new Uri(#"https://apis.live.net/v5.0/me?access_token=" + result.ResponseData[0].Token);
using (var client = new HttpClient())
{
var infoResult = await client.GetAsync(restApi);
string content = await infoResult.Content.ReadAsStringAsync();
var jsonObject = JsonObject.Parse(content);
string id = jsonObject["id"].GetString();
string name = jsonObject["name"].GetString();
}
As to why the WebAccount property doesn't get set... shrugs
And FYI, the "id" returned here is entirely different from the WebAccount.Id property returned with the authentication request.
I am using the EWS Managed API to find an EmailItem and forward it to another recipient. I want to record the ItemId of the forwarded email, but I can't figure out how to find this property.
var originalMail = EmailMessage.Bind(exchangeService, originalMailId);
var fwdMessage = originalMail.CreateForward();
fwdMessage.ToRecipients.Add("foo#bar.com");
fwdMessage.BodyPrefix = new MessageBody(BodyType.HTML, html);
fwdMessage.Subject = "Testing 123";
// Send the message
fwdMessage.SendAndSaveCopy();
How can I get the ItemId of the fwdMessage email?
It seems that the ResponseMessage object doesn't expose an ID. You could try stamping a GUID in a custom extended property before sending, then searching Sent Items for the item that has that GUID.
I'm using the Exchange Web Services Managed API to search a message folder using FindItems. The code I'm using is this:
var search = new SearchFilter.ContainsSubstring(
ItemSchema.Subject,
"subject I want");
ItemView searchView = new ItemView(9999);
searchView.PropertySet = new PropertySet(
BasePropertySet.IdOnly,
ItemSchema.Subject,
ItemSchema.DateTimeReceived,
EmailMessageSchema.From);
searchView.OrderBy.Add(
ItemSchema.DateTimeReceived,
SortDirection.Descending);
searchView.Traversal = ItemTraversal.Shallow;
var searchResults = _service.FindItems(
folderToSearch.Id,
search,
searchView);
The search works fine, and the properties I've specified in the searchView.PropertySet do get returned. The problem is that it doesn't return all of the details of From.
I iterate searchResults, and cast the items to type EmailMessage or PostItem as appropriate, to access the From property, which returns an EmailAddress object. On that object, the Name property is set, but Address is null.
If I then bind the item, like:
var boundItem = Item.Bind(_service, message.Id);
var boundItemEmail = boundItem as EmailMessage;
Then boundItemEmail.From.Address is not null, it returns the senders email address.
The trouble is, binding a message can be a rather time-consuming process, compared to the much faster FindItems operation.
You should be able to use the LoadPropertiesForItems method to get the From property, it's faster than binding to individual messages.
I found a way to achieve this that using the query string "rs:ClearSession" have to pass in URL.
Below is my code ASP.NET SSRS Reportviewer integarating page,
rptvw.ProcessingMode = ProcessingMode.Remote;
rptvw.ServerReport.ReportServerUrl = new Uri("http://localhost/reportserver");
rptvw.ServerReport.ReportPath = "/Northwind/NewNorthwind";
ReportParameter[] param = new ReportParameter[1];
param[0] = new ReportParameter("CustomerID", txtparam.Text);
rptvw.ServerReport.SetParameters(param);
rptvw.ServerReport.Refresh();
Question is where should I pass the query string "rs:ClearSession". I tried in above ReportServerUrl and ReportPath but still getting error might be I have done any syntax errors.
Where and how to pass the query string "rs:ClearSession" in URL ?