POST - To Send an Email with Attachments

 Purpose

The API is used to Send an Email with attachments.  The attachments should be uploaded to the File Store using the 'Upload Attachments' API. The response values, storeName, attachmentName and attachmentPath from that API should be used in the Request Body of this API. 

 Request URL 

https://mail.zoho.com/api/accounts/<accountId>/messages

Note: You can use the API here to retrieve the accountid for the currently authenticated user.

 Request Parameters

ParameterData TypeDescription
accountID*LongaccountID - The unique Zoho Account number associated with the particular account.

* - Mandatory parameters

  Request Body (JSON Object)

ParameterData TypeAllowed ValuesDescription
fromAddress*StringValid from email address corresponding to the account The from Address that should be used in this email.
toAddress*String

Valid recipient email address for the To field

Recipient email addresses for the To field
ccAddressStringValid recipient email address for the Cc fieldRecipient email addresses for the Cc field
bccAddressStringValid recipient email address for the Bcc fieldRecipient email addresses for the Bcc field
subjectStringSubject of the email that should be sent Subject of the email that should be sent 
encodingString

Default value is UTF-8. Other allowed encoding values are listed below

  • Big5
  • EUC-JP
  • EUC-KR
  • GB2312
  • ISO-2022-JP
  • ISO-8859-1
  • KOI8-R
  • Shift_JIS
  • US-ASCII
  • UTF-8
  • WINDOWS-1251
  • X-WINDOWS-ISO2022JP
The encoding which should be used in the email content. 
mailFormatString
  • html
  • plaintext
Whether the email should be sent in HTML format or in plain text. The default value is HTML
attachmentsJSON ArrayJSON Object of attachments 
attachmentNameString Name of the attachmentThe value should be got from the upload Attachments API response
attachmentPathString Path in which the attachment is stored The value should be got from the upload Attachments API response
storeNameString Name of the Store where the attachment is savedThe value should be got from the upload Attachments API response

* - Mandatory parameters

 Response Codes

Please refer Response Codes.

Sample Request

For Single attachment:

Copied{
   "fromAddress": "my@mydomain.com",
   "toAddress": "family@mydomain.com",
   "ccAddress": "colleagues@mywork.com",
   "bccAddress": "restadmin1@restapi.com",
   "subject": "abc",
   "content": "Email can never be dead. The most neutral and effective way, that can be used for one to many and two way communication.",
   "attachments": [
      {
         "storeName": "NN2:-167775813820412438",
         "attachmentPath": "/1425407266885_ourholidays",
         "attachmentName": "ourholidays.jpg"
      }
   ]
}

For Multiple attachments:

Copied{
   "fromAddress": "my@mydomain.com",
   "toAddress": "family@mydomain.com",
   "ccAddress": "colleagues@mywork.com",
   "bccAddress": "restadmin1@restapi.com",
   "subject": "abc",
   "content": "Email can never be dead. The most neutral and effective way, that can be used for one to many and two way communication.",
   "attachments": [
      {
         "storeName": "NN2:-167775813820412438",
         "attachmentPath": "/1425407266885_ourholidays",
         "attachmentName": "ourholidays.jpg"
      },
      {
         "storeName": "NN2:-1677758138204234566",
         "attachmentPath": "/1425407266885_ourvacation",
         "attachmentName": "ourvacation.jpg"
      }
   ]
}