现在我的 web 应用程序快完成了,我想以附件的形式将结果通过电子邮件发送给自己。附件的内容是变量“Gcode”的内容,这是一个大字符串,如下所示:“G00X12.46Y18.51 G01X12.46Y21.62 G01X13.79Y21.62 G00X10.00Y23.00”邮件我收到一条错误消息:TypeError: 'list' object is not callable。我发现附件必须是字节串。这是问题吗?
class send_mail(webapp2.RequestHandler):
def post(self):
material = self.request.get('material')
thickness = self.request.get('thickness')
fileName = self.request.get('fileName')
Gcode = self.request.get('Gcode')
sheetSize = self.request.get('sheetSize')
recieve_address = 'me@hotmail.com'
attachments=[(fileName+'.nc', 'Gcode')]
if not mail.is_email_valid(user_address):
Gcode = ''
else:
confirmation_url = Gcode
sender_address = "theLaserLab.com <theLaserLab@gmail.com>"
subject = "Order content"
body = "The attached file: %s.nc. Is supposed to cut from a sheet of %s that is %smm thick and has a %s dimension." % (fileName, material, thickness, sheetSize)
mail.send_mail(sender_address, recieve_address, subject, body, attachments)