What API can I use to pull/read only new email messages (in XML or JSON)"

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
shawns
Posts: 13
Joined: Wed Feb 08, 2023 3:40 pm

What API can I use to pull/read only new email messages (in XML or JSON)"

Post by shawns »

What API can I use to pull/read only new email messages (in XML or JSON)"

Can't seem to find a right API. I was looking at: http://server/home/username/?fmt=XML&query="in:inbox is:unread", but not sure if this is the correct one

Also can't seem to find online a sample of email messages that are returned

Please help, thanks!

Shawn
User avatar
barrydegraaff
Zimbra Employee
Zimbra Employee
Posts: 242
Joined: Tue Jun 17, 2014 3:31 am
Contact:

Re: What API can I use to pull/read only new email messages (in XML or JSON)"

Post by barrydegraaff »

--
Barry de Graaff
Email: barry.degraaff [at] synacor [dot] com
Admin of Zimbra-Community Github: https://github.com/orgs/Zimbra-Community/ and the
Zimlet Gallery https://gallery.zetalliance.org/extend/
User avatar
barrydegraaff
Zimbra Employee
Zimbra Employee
Posts: 242
Joined: Tue Jun 17, 2014 3:31 am
Contact:

Re: What API can I use to pull/read only new email messages (in XML or JSON)"

Post by barrydegraaff »

Response looks like attached:
Attachments
Screenshot from 2023-02-08 17-28-49.png
Screenshot from 2023-02-08 17-28-49.png (141.79 KiB) Viewed 3945 times
--
Barry de Graaff
Email: barry.degraaff [at] synacor [dot] com
Admin of Zimbra-Community Github: https://github.com/orgs/Zimbra-Community/ and the
Zimlet Gallery https://gallery.zetalliance.org/extend/
shawns
Posts: 13
Joined: Wed Feb 08, 2023 3:40 pm

Re: What API can I use to pull/read only new email messages (in XML or JSON)"

Post by shawns »

Thanks, Barry for the help!

I can't seem to be able to access the example.com link: https://zimbra.example.com/home/username

And looking at the attached xml response, how can I tell which elements are for From, To, Subject, Date/Time Received and email Body? (I can't seem to find where in documentation these elements are defined in xml/json email messages)

Thanks, again!
shawns
Posts: 13
Joined: Wed Feb 08, 2023 3:40 pm

Re: What API can I use to pull/read only new email messages (in XML or JSON)"

Post by shawns »

And I'd appreciate it if there is sample code (can't seem to access https://zimbra.example.com/home) to call API: http://server_name/home/account_name/inbox?fmt=xml&query=is:unread
in a .NET C# application

And is the account_name the same as Zimbra email address?

Thanks!

Shawn
User avatar
L. Mark Stone
Ambassador
Ambassador
Posts: 2796
Joined: Wed Oct 09, 2013 11:35 am
Location: Portland, Maine, US
ZCS/ZD Version: 10.0.6 Network Edition
Contact:

Re: What API can I use to pull/read only new email messages (in XML or JSON)"

Post by L. Mark Stone »

shawns wrote:Thanks, Barry for the help!

I can't seem to be able to access the example.com link: https://zimbra.example.com/home/username

And looking at the attached xml response, how can I tell which elements are for From, To, Subject, Date/Time Received and email Body? (I can't seem to find where in documentation these elements are defined in xml/json email messages)

Thanks, again!
Please replace the fqdn zimbra.example.com with the fqdn of your Zimbra server.

Hope that helps,
Mark
___________________________________
L. Mark Stone
Mission Critical Email - Zimbra VAR/BSP/Training Partner https://www.missioncriticalemail.com/
AWS Certified Solutions Architect-Associate
shawns
Posts: 13
Joined: Wed Feb 08, 2023 3:40 pm

Re: What API can I use to pull/read only new email messages (in XML or JSON)"

Post by shawns »

Isn't there a link to see some sample .NET code that can call Zimbra APIs?

I just need sample C# code that can call a Zimbra API like 'http://server_name/home/account_name'

Thanks!
User avatar
L. Mark Stone
Ambassador
Ambassador
Posts: 2796
Joined: Wed Oct 09, 2013 11:35 am
Location: Portland, Maine, US
ZCS/ZD Version: 10.0.6 Network Edition
Contact:

Re: What API can I use to pull/read only new email messages (in XML or JSON)"

Post by L. Mark Stone »

shawns wrote:Isn't there a link to see some sample .NET code that can call Zimbra APIs?

I just need sample C# code that can call a Zimbra API like 'http://server_name/home/account_name'

Thanks!

No samples to my knowledge. How you choose to make use of https://wiki.zimbra.com/wiki/Zimbra_REST_API_Reference is up to you.
___________________________________
L. Mark Stone
Mission Critical Email - Zimbra VAR/BSP/Training Partner https://www.missioncriticalemail.com/
AWS Certified Solutions Architect-Associate
shawns
Posts: 13
Joined: Wed Feb 08, 2023 3:40 pm

Re: What API can I use to pull/read only new email messages (in XML or JSON)"

Post by shawns »

Hi Mark, Can I ask this?

When I access http API (http://servername/home/username/inbox?f ... =is:unread), I get an error - "Unable to connect to the remote server". When I access https API (https://servername/home/username/inbox? ... =is:unread), I get an error - "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel". Does this mean I need to provide a credential to the https API, and if yes, how do I provide a credential to the https API call?

Thanks,
Shawn
User avatar
L. Mark Stone
Ambassador
Ambassador
Posts: 2796
Joined: Wed Oct 09, 2013 11:35 am
Location: Portland, Maine, US
ZCS/ZD Version: 10.0.6 Network Edition
Contact:

Re: What API can I use to pull/read only new email messages (in XML or JSON)"

Post by L. Mark Stone »

shawns wrote:Hi Mark, Can I ask this?

When I access http API (http://servername/home/username/inbox?f ... =is:unread), I get an error - "Unable to connect to the remote server". When I access https API (https://servername/home/username/inbox? ... =is:unread), I get an error - "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel". Does this mean I need to provide a credential to the https API, and if yes, how do I provide a credential to the https API call?

Thanks,
Shawn
Hi Shawn,

I'm not a developer but yes, you do need an authentication token. I believe this is discussed somewhere in the https://wiki.zimbra.com/wiki/Zimbra_REST_API_Reference

Hope that helps!
Mark
___________________________________
L. Mark Stone
Mission Critical Email - Zimbra VAR/BSP/Training Partner https://www.missioncriticalemail.com/
AWS Certified Solutions Architect-Associate
Post Reply