How to know which mailFolder is the Inbox? - microsoft-graph-api

Calling /users/me/mailFolders returns the folders list with their id, displayName, parentFolderId, and some counters.
How can I determine which folder is the "Inbox"?
I cannot use displayName because this will probably be in the user's native language. And the Id is just a random string.
I need this because my app populates the list of folders and I want to default the "selection" to the Inbox (just like Outlook does).

For the default folders, you can use a "well-known name" (in this case inbox) to get the correct id. From the documentation:
Outlook creates certain folders for users by default. Instead of using the corresponding folder id value, for convenience, you can use
the following well-known folder names when accessing these folders in a mailFolder collection: ArchiveRoot, ConversationHistory, DeletedItems,
Drafts, Inbox, JunkEmail, Outbox, and SentItems.
To illustrate, calling /me/mailFolders/inbox in the sample Graph Explorer tenant returns:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('48d31887-5fad-4d73-a9f5-3c356e68a038')/mailFolders/$entity",
"id": "AAMkAGVmMDEzMTM4LTZmYWUtNDdkNC1hMDZiLTU1OGY5OTZhYmY4OAAuAAAAAAAiQ8W967B7TKBjgx9rVEURAQAiIsqMbYjsT5e-T7KzowPTAAAAAAEMAAA=",
"displayName": "Inbox",
"parentFolderId": "AAMkAGVmMDEzMTM4LTZmYWUtNDdkNC1hMDZiLTU1OGY5OTZhYmY4OAAuAAAAAAAiQ8W967B7TKBjgx9rVEURAQAiIsqMbYjsT5e-T7KzowPTAAAAAAEIAAA=",
"childFolderCount": 2,
"unreadItemCount": 59,
"totalItemCount": 60
}

In v1.0, I think you'll have to use the localized display names which as you mentioned, can be quite tricky. However, if you use the /beta/ endpoint, you can use the wellKnownName property which is a non-localized identifier for a given mailFolder (eg. 'junkemail', 'inbox', etc).

Related

SendGrid API - Cannot use dynamic template data with a legacy template

Trying to follow the sample here https://docs.sendgrid.com/ui/sending-email/how-to-send-an-email-with-dynamic-templates,
I'm sending the following JSON to this url: "https://api.sendgrid.com/v3/mail/send" (and I have sent a simple email before using the same code, now I want to try a template with substitution):
{
"personalizations": [
{
"subject": "Test template email from SendGrid",
"to": [
{
"name": "Neal Walters",
"email": "myRecipient#example.com"
}
],
"dynamic_template_data": {
"Applicant_Name": "John Doe",
"Send_Date": "December 30, 2022"
}
}
],
"from": {
"name": "NealWalters(SendGrid)",
"email": "mySender#example.com"
},
"template_id": "bcab1b12-d922-4cdd-b6f5-9f39b16d9823"
}
and getting this cryptic error:
{"errors":[{"message":"Cannot use dynamic template data with a legacy template
ID","field":"personalizations.0.dynamic_template_data","help":null}]}
I have no idea what is a dynamic nor a legacy template. I copied one of Send Grid's demo templates (Nonprofit Newsletter Email Template) and added some of my own tags.
When I used the template name ("NealDemo Duplicate Nonprofit Newsletter Email Template") instead of the GUID (which I got from the URL when I was editing the template), the message was similar but added this to the above error - which leaves me with the question of can I use the template name or not? It's unclear what a "template_id" is on how to find it, if it is not the name of the template as I saved it.
{"message":"The template_id must be a valid GUID,
you provided 'NealDemo Duplicate Nonprofit Newsletter Email Template'.","field":"template_id","help":"http://sendgrid.
com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.template_id"},{"message":"Unless a valid template_id is
provided, the content parameter is required. There must be at least one defined content block. We typically suggest
both text/plain and text/html blocks are included, but only one block is required.","field":"content","help":"http://s
endgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.content"}]}
Disappointed these are not listed on this errors page:
https://docs.sendgrid.com/api-reference/mail-send/errors
Are there two template editors?
I used this one:
https://mc.sendgrid.com/design-library/your-designs/bcab1b12-d922-4cdd-b6f5-9f39b16d9823/editor
I didn't see any other guid/id for the template, so I tried "bcab1b12-d922-4cdd-b6f5-9f39b16d9823" from the URL.
But now I see there is also a dynamic template editor???
https://mc.sendgrid.com/dynamic-templates
As mentioned below, I copied one of your demo templates, which already had some substitution variables in at the bottom ({{Sender_Name}}
{{Sender_Address}}, {{Sender_City}}, {{Sender_State}} {{Sender_Zip}}). I just added two of my own at the top.
I have referenced this: Getting "Cannot use dynamic template data with a legacy template" with non-legacy template
The saga continues. I went to this page: https://mc.sendgrid.com/dynamic-templates and was able to copy over my previous template, so perhaps it was a legacy template. It now gave it a clearly labeled template-id of: d-a35d9d48ce304588bbebf7828811b473 (which looks like a "d-" followed by a guid).
I ran that through the API call, which resulted in no immediate errors, but then I got this email:
Usually when I can't figure things out, it is either the documentation is lacking, or I was speed-reading it.
When I first setup my account, I apparently clicked a link that took me to SendGrid's main site, and I signed up for an account there. Apparently this step was totally unnecessary (also their site requires a 2FA, separate from Azure). So I built my templates on their site, which was under a different account then the one I created in Azure. Thus I was able to send emails with the token from Azure, but any time I tried to send a template from my second account, of course, it was not recognized with my Azure account.
You can create templates inside of Azure, from the links shown below:
Then this:
NOTE 1 - their "pretty" designs are still under the Legacy Templates, and "Dynamic Templates" seem to be the newer preferred way to go. You can build a "legacy template", then apparently copy it's HTML over to a "dynamic template".
NOTE 2 - I only solved this by opening a support ticket with SendGrid.

How to list down all aliases of Office365 account using Microsoft Graph API?

How to list down all aliases of Office365 account using Microsoft Graph API? Is there a separate permission level I need to provide or different parameter in API https://graph.microsoft.com/v1.0/me/ to get the list of all aliases. Any help is appreciated.
The default alias is stored in mailNickname property. The full list of assigned aliases/addresses are stored in the proxyAddresses property collection. These include additional aliases and domains, so you may need do a little processing to split each address at # and dedupe the first element.
To retrieve these you would need to specifically request the properties you want using the $select query parameter:
/v1.0/me?$select=id,userPrincipalName,displayName,mailNickname,proxyAddresses
Using Graph Explorer's demo data, you would see this result:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(id,userPrincipalName,displayName,mailNickname,proxyAddresses)/$entity",
"id": "48d31887-5fad-4d73-a9f5-3c356e68a038",
"displayName": "Megan Bowen",
"mailNickname": "MeganB",
"proxyAddresses": [
"SMTP:MeganB#M365x214355.onmicrosoft.com"
],
"userPrincipalName": "MeganB#M365x214355.onmicrosoft.com"
}

How to get in-place archive custom folder name on office 365?

GET mailFolders/archivemsgfolderroot
I use distinguish name to get this in-place mailbox folder
and the response is:
...
"displayName": "Top of Information Store",
...
However, this is not the custom name I modified on office365.
Is it possible to get that custom name?
I also try to get distinguish folder in EWS managed API
<t:DistinguishedFolderId Id="archivemsgfolderroot" />
It returns the same name
...
<t:DisplayName>Top of Information Store</t:DisplayName>
...
--
Add two image ref.
how I add it
how it looks like at outlook
thanks for help
I see that a user can set a property, "ArchiveName", to give their archive mailbox a custom name. In powershell, this would be using a Set-Mailbox cmdlet.
https://learn.microsoft.com/en-us/powershell/module/exchange/mailboxes/set-mailbox?view=exchange-ps
That doc states that it applies to Outlook and OWA and, after a quick look, I can't see a way to get that property other than using Get-Mailbox which is not ideal. So as best I can tell it's not exposed through EWS or REST and thus probably isn't available through Microsoft Graph.
I would encourage you to file a suggestion: https://officespdev.uservoice.com/forums/224641-feature-requests-and-feedback/category/101632-microsoft-graph-o365-rest-apis
You can try the following endpoint
https://graph.microsoft.com/v1.0/me/mailFolders/archivemsgfolderroot/childFolders/AAMkADQ5OWMzMGEwLTg4ZjktNDk1Ny05NzFmLWRhZjg4ODU0YzUwYwAuAAAAAACtqDzk9UzLSpZsdesjndr1AQBNzq1HG8BvRYqBQbPeZSPaAAGdwZCCAAA=
(Replace the id to yours):https://graph.microsoft.com/v1.0/me/mailFolders/archivemsgfolderroot/childFolders/id

Cumulocity smarREST response templates

I am trying to set up the Cumulocity smartREST response templates to supply info from the device object stored by an app. I am thinking it is not possible but I want to confirm because the documentation is brief and not clear.
I have successfully implemented MEASUREMENT POST templates previously but I am trying to do INVENTORY GET now. I have set some values in the device object and I can see them from tenant.cumulocity.com/inventory/managedObjects/id/. This could look like:
"custom_values": {
"val1": "abcde",
"val2": "fghij"
}
Now I go to the smartREST template web interface editor and create a template (eg t1) and set a message (eg m001) and set it to 'inventory' and 'get' and tick 'includes response'. I'm not sure if I need custom fields here. Then I create a response (eg r001) and I now have to fill in base pattern with a condition and some number of other patterns. I assume in one of those fields I have $.custom_values.val1 etc but all permutations I try result in 'no access to object' error from topic 's/e'.
My ideal result (from the above example) would be to publish to '/s/uc/t1' with 'm001' and receive 'r001,abcde' (ie custom_values.val1) and publish 'm002' and receive 'r001,fghij' (ie custom_values.val2).
Thanks for taking the time to read.
Your approach is correct but your MQTT user probably is just missing the rights to the object as it is created by the app (I guess the mqtt client is a device user).
The best approach here is to give this object you are creating from the app the fragment c8y_Global
{
"name": "testObject3",
"c8y_Global": {},
"custom_values": {
"val1": "abcde",
"val2": "fghij"
}
}
This fragment will make this object available to all registered users. This is common practice for app meta data.

Using Ruby on Rails 5, how do I define a URL route with unknown/:folder/:sub-folder depth and save/recall it from Postgresql?

In my application, users will be able to create categories and I would like the "breadcrumb" to be visible in the URL, i.e.
www.domain.com/user/:user_id/folder/:top-folder-slug/:sub-folder-slug/:sub-sub-folder-slug
I do not intend to have a limit on the levels of sub-folders a user can create so I'm needing to know if it is possible to define a route in Rails that will accept an unknown amount of folder parameters and, idealy, make them available to me with a sequential number appended to the params (params[folder1], params[folder2]). Is this possible?
This presents another challange as to how to store the entire breadcrumb in the database, as I can't just dynamically add "folder 1", "folder 2", etc, columns as needed and I'm not sure the performance/scalability of storing it all in jsonb column. Perhaps it would be necessary to only display parent-folder and current-folder in the URL and database, (i.e. below) and just query base on those?
www.domain.com/user/:id/folder/.../parent-folder/current-folder
Any insight on how to get to where I'm after would be appreciated.

Resources