I'm trying to follow the API document and send an email by using my sheet.
Here is the code:
email = smartsheet.models.MultiRowEmail()
email.send_to = smartsheet.models.Recipient({
'email': '[email protected]'
})
email.row_ids=[rowId]
email.column_ids = [columnID]
# Send rows via email
response = smartsheet_client.Sheets.send_rows(
sheet_id, # sheet_id
email)
It keeps giving me error message below,
{"response": {"statusCode": 400, "reason": "Bad Request", "content": {"errorCode": 1012, "message": "Required object attribute(s) are missing from your request: multipleRowsEmail.rowIds[], multipleRowsEmail.includeAttachments, multipleRowsEmail.includeDiscussions.", "refId": "lvre2gkxtm8m"}}}
Please advise, Thanks
Part of the problem is that you need to also specify the include_attachments
property and the include_discussions
property on the email
object. These properties are required. (As a sidenote, I notice that the Python code snippet for Send Rows via Email in the API docs incorrectly omits these two properties...hopefully someone from Smartsheet sees this thread and can fix that issue in the docs.)
Not sure why the error message indicates that row IDs are missing from the request, as it looks like you're populating Row IDs. I'd suggest that you investigate to make sure that your [rowId]
property (that you're using to set the value of email.row_ids
in the request) actually is a populated array of Row IDs.
The following code example successfully sends an email that contains the specified 4 rows and 2 columns of data:
# specify IDs
sheet_id = 3932034054809476
row_ids = [4324392993613700, 5225480965908356, 657918269646724, 721881338537860]
column_ids = [6101753539127172, 4055216160040836]
# build email object
email = smartsheet.models.MultiRowEmail()
email.send_to = smartsheet.models.Recipient({
'email': '[email protected]'
})
email.row_ids = row_ids
email.column_ids = column_ids
email.include_attachments = False
email.include_discussions = False
# send rows via email
response = smartsheet_client.Sheets.send_rows(
sheet_id,
email)