How to send New Email with Attachment using Zimbra API

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
VistoPartner
Posts: 16
Joined: Fri Sep 12, 2014 11:56 pm

How to send New Email with Attachment using Zimbra API

Post by VistoPartner »

Hi Guys,
I was trying to figure out how to send a new Email with attachment. When I looked at the soap.txt file, I saw that I have to upload the attachment first and then use the returned attachment-upload-ID for the SendMsgRequest.
I couldn't find any example or how to use the FileUploadServlet. Can anybody help me where to look for an example?
Thanks.
parin
Posts: 28
Joined: Sat Sep 13, 2014 3:06 am

How to send New Email with Attachment using Zimbra API

Post by parin »

I have same problem.. there is no guide how to upload and use that id in request... did you get the solution ??
13546dalmate
Outstanding Member
Outstanding Member
Posts: 360
Joined: Fri Sep 12, 2014 11:59 pm

How to send New Email with Attachment using Zimbra API

Post by 13546dalmate »

Hope you know how to use SOAP by java.

You can use 2 SOAP requests to do this thing: FileUploadServlet and SendMsgRequest.

In the first step, you use FileUploadServlet to upload your message to server and get message's id from FileUploadServlet's response.

In SendMsgRequest, it has an attribute aid, all you need is giving it message's id.
parin
Posts: 28
Joined: Sat Sep 13, 2014 3:06 am

How to send New Email with Attachment using Zimbra API

Post by parin »

thank you dalmate for your reply. i know there are two steps to upload a file on server. but it would be best if the sample code is available to upload any file to zimbra. i know how to send message and how to add attachment id v. but don't know the exact code example about how to upload it.
Thank You
parin
Posts: 28
Joined: Sat Sep 13, 2014 3:06 am

How to send New Email with Attachment using Zimbra API

Post by parin »

here is a link to a full documentation of zimbra soap API :- SOAP API Reference Material Beginning with ZCS 8.0 - Zimbra :: Wiki
13546dalmate
Outstanding Member
Outstanding Member
Posts: 360
Joined: Fri Sep 12, 2014 11:59 pm

How to send New Email with Attachment using Zimbra API

Post by 13546dalmate »

[quote user="parin"]here is a link to a full documentation of zimbra soap API :- SOAP API Reference Material Beginning with ZCS 8.0 - Zimbra :: Wiki[/QUOTE]

If you want to upload file to Zimbra, don't use SOAP because Zimbra does not have this service.

I recommend you use httpupload to upload to this url: http[s]://yourdomain.com/service/upload
manawa
Posts: 5
Joined: Mon Feb 15, 2016 7:02 am

Re: How to send New Email with Attachment using Zimbra API

Post by manawa »

13546dalmate wrote:
In the first step, you use FileUploadServlet to upload your message to server and get message's id from FileUploadServlet's response.

.
Actually I don't get any ID from the FileUploadServlet's response.

The response I get is something like

Code: Select all

200, null, 2443203b-c634-4404-be27-d837c7f7fbb7:3fbf9648-7977-40f7-8ee0-f20119d6cdbf
with the last number being a server token I presume.

How to get the uploaded file ID please ?
manawa
Posts: 5
Joined: Mon Feb 15, 2016 7:02 am

Re: How to send New Email with Attachment using Zimbra API

Post by manawa »

parin wrote:thank you dalmate for your reply. i know there are two steps to upload a file on server. but it would be best if the sample code is available to upload any file to zimbra. i know how to send message and how to add attachment id v. but don't know the exact code example about how to upload it.
Thank You
Hello Parin,

Did you managed to get the upload working and get message's id from FileUploadServlet's response ?
Thanks
dvidalg
Posts: 2
Joined: Tue Jul 28, 2020 2:34 pm

Re: How to send New Email with Attachment using Zimbra API

Post by dvidalg »

manawa wrote:
13546dalmate wrote:
In the first step, you use FileUploadServlet to upload your message to server and get message's id from FileUploadServlet's response.

.
Actually I don't get any ID from the FileUploadServlet's response.

The response I get is something like

Code: Select all

200, null, 2443203b-c634-4404-be27-d837c7f7fbb7:3fbf9648-7977-40f7-8ee0-f20119d6cdbf
with the last number being a server token I presume.

How to get the uploaded file ID please ?

Hi manawa,

I'm new on this and trying to send an email with attachment with soap.
I get an error when uploading the attachment to /service/upload, probably because I'm not doing right with the content then use httpPost.setEntity
I think you got it and that "2443203b-c634-4404-be27-d837c7f7fbb7:3fbf9648-7977-40f7-8ee0-f20119d6cdbf" is the aid (attachment id)

Could you tell me what java code you used to make the post to upload the attachment file?


Thanks and best regards :)
User avatar
barrydegraaff
Zimbra Employee
Zimbra Employee
Posts: 242
Joined: Tue Jun 17, 2014 3:31 am
Contact:

Re: How to send New Email with Attachment using Zimbra API

Post by barrydegraaff »

In Java you can do:
https://github.com/Zimbra-Community/zim ... .java#L480


In javascript you can do:
https://github.com/Zimbra-Community/rma ... l.js#L1511

From the CLI on Zimbra you can use:
cat /tmp/youremailmsg | /opt/zimbra/common/sbin/sendmail account@example.com
see: https://help.dreamhost.com/hc/en-us/art ... -Sendmail-
--
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