Original mail in JS

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
Post Reply
Roussart
Posts: 1
Joined: Thu May 27, 2021 9:44 am

Original mail in JS

Post by Roussart »

Hello,

I'm working on a zimlet that would allow the user to save mail attachments and other to another server. My problem is that I can't find specific data about the mail object in my Javascript code. Let me explain :

Until now, I've been using this line of javascript code to retrieve an array of "ZmMailMsg" objects.

Code: Select all

var mail = controller.getSelection();
The problem is, my "mail" variable is missing the actual content of pdf attachment for instance. It's also missing "text/plain" content which is the content I need. I can only find "text/html" content even though my mail should be multipart. (see console output under)
no-text-content.png
no-text-content.png (10.89 KiB) Viewed 10328 times
Now I'm giving up using this ZmMailMsg object. I just want one to do one very simple thing : get the original mail inside of my Javascript code, and I'll do the formatting myself.
When you're using the user interface, you can right click on a mail and "Show original", well, now I want to get the same result but inside of my JS. Please, does anyone have an idea how to proceed ?

Thanks !

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

Re: Original mail in JS

Post by barrydegraaff »

You can use the REST api, basically use an XMLHttp request using https://wiki.zimbra.com/wiki/Zimbra_RES ... e:Get_Item

example:

https://github.com/Zimbra-Community/own ... t.js#L1327

The ID of the message, you can get from the ZmMsg that you have.
--
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/
Post Reply