2
Query e-mails within a specific folder using GetMessages SmarterMail API v1
Question asked by krystal - 1/13/2021 at 7:48 AM
Answered
Hi Everyone,

I am trying to get the number of messages received within a certain timeframe. I am using the API below and was able to get messages however it seems to return all messages in the folder and doesn't seem to get the exact number of messages for the dates entered in "MessagesBefore" and "MessagesSince".

POST api/v1/mail/messages 
https://mail.smartertools.com/Documentation/api#/reference/SmarterMail.Web.Controllers.Api.MailController/GetMessages


Can anyone help me understand how messages can be properly queried using this API? Below is my post input, I didn't provide a query on it because I'm not sure how to query it, I tried to enter it in Odata format (in the URI and in the post input/body) but it still returns everything.

{  
"fieldsToSearch""Date",  // tried to use InternalDate here
"messagesSince""2021-01-12T00:00:00Z",  
"messagesBefore""2021-01-13T23:59:00Z",  
"ownerEmailAddress""user@domain.com",  
"folder""Read Receipts",  
"sortType""Date",  
"sortAscending"0
}

4 Replies

Reply to Thread
0
krystal Replied
I'm still unable to figure out how the messages within a folder can be filtered. Does anyone know? Is it even possible?
0
Ludovic de RENTY Replied
Hi Community,

I have exactly the same need as krystal, and the same misunderstanding about the usage of "messagesSince" and/or "messagesBefore".
Can anyone help us ?
0
Zach Sylvester Replied
Employee Post Marked As Answer
Hello Everyone, 

I was able to get this working using the following JSON. 
{"searchCriteriaMap":{"dateAfter:email:received:after":"2022-01-31T23:59:59-07:00","dateBefore:email:received:before":"2022-03-01T00:00:00-07:00"},"section":1,"or":false}
Please give it a try and let me know if you have any questions. 

Kind Regards, 
Zach Sylvester
Technical Support Specialist
SmarterTools Inc.
(877) 357-6278
www.smartertools.com
0
Ludovic de RENTY Replied
Thank you Zach for answering!

Unfortunatly, I'm not able to get your sample working for me, the API GetMessages still returns all the emails received in the folder.
Important information: I currently use the version 7242 of SmarterMail, which is not very up-to-date! Maybe it can explain this filtering is not working for me :-/

Reply to Thread