Using 7.9.23. Trying to send a report with the following script -
def sendReport(endDateDT=None):
"""
How will we determine what counts as marked? should marked really be a datetime? Perhaps. Or based on when the entry was entered?
An old entry from months ago that gets marked this week - should that be sent for instance.
"""
LOGGER.info("Trying to send report")
if endDateDT is None:
endDateDT = system.date.now()
LOGGER.info("Using date %s"%(str(endDateDT)))
reportName = 'DPD Weeklies Projects Updates'
action = 'email'
reportParameters = {'endDate':endDateDT}
endDate = system.date.format(endDateDT, 'yyyy-MM-dd')
project = 'DPDWeeklies'
body = "Cooleagues,\n\nBelow are the project updates for the week.\n\nPlease feel free to reach out if you have any questions regarding the updates.\n\nThanks"
actionSettings = {'to':['keyur.parikh@bms.com'], 'smtpServerName':'Weekly Hot Topics Mailer', 'from':'DPDWeeklies@bms.com', 'subject':'DPD Weeklies w/e %s'%(endDate),"body":body}
reportData = system.report.executeReport(path=reportName, project=project, parameters=reportParameters, fileType='pdf')
fileName = 'DPD Weeklies Updates %s'%(str(endDate))
print fileName
print type(reportData)
system.net.sendEmail(smtpProfile='Weekly Hot Topics Mailer', fromAddr='testEmail@test.com', subject='DPD Weeklies w/e %s'%(endDate), body=body, to=['testEmail@test.com'], attachmentNames=[fileName], attachmentData=[reportData])
# system.report.executeAndDistribute(path=reportName, project=project, parameters=reportParameters, action=action, actionSettings=actionSettings)
LOGGER.info("Finished trying to send report")
I am getting an error on the system.net.sendEmail part the error and not sure why. Apologies for screen shot, operator is remoted in a few layers deep and cannot copy paste for some reason -
My sendEmail line does work if I leave off the attachmentNames and attachmentData kwargs, so I hting that is the issue but I don't know why. My print statements shows the filename to be DPD Weeklies Updates 2023-08-18
and the type of reportData
as <type 'array.array'>
. Any ideas what is going on?