Filtering emails by attachment name EWS managed api C# - exchange-server

I was trying to filter emails based on their attachments. So i am filtering based on the attachment name to be more precise.
Filtering with AQS ("attachments: picture.jpg") works fine and i get the right results.
But when i use SearchFilters i get no results. I am using the following command:
var filter = new SearchFilter.ContainsSubstring(EmailMessageSchema.Attachments, "picture.jpg");
I even used the explicit filter parameters but still get no results.
var filter = new SearchFilter.ContainsSubstring(EmailMessageSchema.Attachments,"picture.jpg", ContainmentMode.Substring, ComparisonMode.IgnoreCase);
I use Exchange Server 2016/2019.

Related

Google Cloud Document AI processing response impossible to get Form Fields in PHP

I cannot get form fields values from processing a response in PHP when using a Google Cloud Document AI with a custom processor where the form fields are defined. google-cloud only has documentation for Java, C#, Pyton... How can I get my data? When I tested it in googe-cloud then everything worked...
I try to looping over pages en so trying to get formFields but nothing works.
Custom Document Extractor returns the extracted data in the entities field, not formFields.
The Form Parser Processor is currently the only processor that populates the formFields field.
You can use this example to follow the logic for how to handle the response for Entity Extraction processors.
https://cloud.google.com/document-ai/docs/handle-response#entities_nested_entities_and_normalized_values

Filter Microsoft Graph List Messages API to only received messages

Goal: I'd like to be able to filter the "List Messages" API to only return emails that are sent to the user rather than any messages that exist anywhere (such as ones sent out by the user).
Right now, if you query this particular API, you get a list of all of the messages in all folders (including Deleted Items and Clutter folders).
I know that I can filter on isDraft eq false to remove the drafts - but I don't know if there's any filter to say don't include messages sent by the user.
What I've Tried: I've looked over the examples and didn't see anything about filtering like this. I've also taken a look at the OData Query Params and dug into the filter param. The problem is I'm not quite sure what I could even filter on. I do see that there is a sender parameter - but given I've connected via OAuth and haven't asked users to provide their email address I'm not sure I have an easy way to filter on that.
Theoretically, I could first do a request to the https://graph.microsoft.com/beta/me/ endpoint to get the userPrincipalName and then add a filter on from/emailAddress/address ne '<userPrincipalName>' when I call the /me/messages endpoint - but that's going to double the number of API calls I'd need to make. Is that the only option I have or is there a better way to go about this?
Thanks for your time :)
There is no filter parameter that will achieve this directly. If you want to filter away sent messages - you'll need to either decode the base64 encoded JWT access token and extract the userPrincipalName or make a call to the /me endpoint and retrieve the userPrincipalName from that. Once you have that, you can add a filter of from/emailAddress/address ne '<userPrincipalName>'.
Please note that if you are filtering on many things and you have an "order by" param that you'll need to include that param in your filter or you'll receive an error about too many filters.

Using SwiftyJSON with Gmail API

I am trying to make a simple email app to learn how to work with REST API's like the Gmail API and Im using SwiftyJSON to work with the responses I get from my requests.
I'm trying to get who the sender of an email. Im using the following requests to get the message object back. https://developers.google.com/gmail/api/v1/reference/users/messages/get
From the JSON Data I need to go to the following path (payload>headers>from) to get who sent the message now I have tried all the ways that are specified on the github page.
//Getting a string using a path to the element
let path = [1,"list",2,"name"]
let name = json[path].string
//Just the same
let name = json[1]["list"][2]["name"].string
//Alternatively
let name = json[1,"list",2,"name"].string
All of these ways return null.
Now when i do the following i get the payload object of the message object in return
let from = json["payload"]
What am I doing wrong here?

Google Custom Search API - Engine Retrieving Engine Data Fails

I need to do CRUD on Custom Search Engines. From documentation, it looks pretty straight forward. I keep getting 401 responses though.
I am using Google.Apis.Oauth2.v2 to get a token:
String serviceAccountEmail = "blahblahblah#developer.gserviceaccount.com";
var certificate = new X509Certificate2(#"key.p12", "blah", X509KeyStorageFlags.Exportable);
var credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { "https://www.googleapis.com/auth/cse" }
}.FromCertificate(certificate));
bool result = credential.RequestAccessTokenAsync(CancellationToken.None).Result;
TokenResponse token = credential.Token;
I then add the token to the following request (Authorization: Bearer mytoken):
GET http://cse.google.com/api/<USER_ID>/cse/<CSE_ID>
There are a few things that jump at me.
Exact quote from documentation:
Although you can set HTTP requests to the URL http://cse.google.com/api/[USER_ID]/cse/[CSE_ID], we recommend using
the following URL instead:
http://cse.google.com/api/[USER_ID]/cse/[CSE_ID]
Note that both URL's are exactly the same.
In authentication section, the sample is using ClientLogin, which is deprecated. No samples with OAuth 2.0.
In the document's example, it says:
Each Custom Search engine is identified by a unique ID created by
combining a user ID with a Custom Search engine ID, separated by a
colon, like this:
011737558837375720776:mbfrjmyam1g In this case, the user ID is
011737558837375720776, and the search engine ID is mbfrjmyam.
You would have noticed that the search engine ID is 2 characters short of what it looks like should be.
Nowhere I have seen the scope as "https://www.googleapis.com/auth/cse". I just copied it from a stackoverflow post.
I understand this is a very long question, but I hope this will help the next person to look at this and consider these points.
Anyone knows why the 401s?

Klatura API: How do I retrieve a list of all media entries, not just those that have content?

I'm using the Kaltura v3 API, uploading a video to the server. I'd like to be able to query the API and ask if I have a MediaEntry added, but with no media (or upload token) associated with it. It seems like media:list would be the correct action, but it doesn't return any results that don't have media already associated.
Is there a parameter I can send to media:list to get these entries? Or another API call I should be using?
If you're looking to list all media entries that don't have video associated, use the following. Example is in PHP, but will be the same in every language if you use a client library -
$filter = new KalturaMediaEntryFilter();
$filter->statusEqual = KalturaEntryStatus::NO_CONTENT;
$result = $client->media->listAction($filter);

Resources