Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Email 为Google App Engine创建附件_Email_Google App Engine_Attachment - Fatal编程技术网

Email 为Google App Engine创建附件

Email 为Google App Engine创建附件,email,google-app-engine,attachment,Email,Google App Engine,Attachment,现在我的webapp快完成了,我想把结果以附件的形式发送给我自己。附件的内容是变量“Gcode”的内容这是一个大字符串,看起来像: “G00X12.46Y18.51 G01X12.46Y21.62 G01X13.79Y21.62 G00X10.00Y23.00“ 当尝试发送邮件时,我收到一个错误:TypeError:“list”对象不可调用。我发现附件必须是bytestring。这就是问题所在吗 class send_mail(webapp2.RequestHandler): def pos

现在我的webapp快完成了,我想把结果以附件的形式发送给我自己。附件的内容是变量“Gcode”的内容这是一个大字符串,看起来像: “G00X12.46Y18.51 G01X12.46Y21.62 G01X13.79Y21.62 G00X10.00Y23.00“ 当尝试发送邮件时,我收到一个错误:TypeError:“list”对象不可调用。我发现附件必须是bytestring。这就是问题所在吗

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)
类发送邮件(webapp2.RequestHandler):
def post(自我):
material=self.request.get('material')
厚度=self.request.get('thickness')
fileName=self.request.get('fileName')
Gcode=self.request.get('Gcode')
sheetSize=self.request.get('sheetSize')
接收地址:me@hotmail.com'
附件=[(文件名+'.nc',Gcode')]
如果不是邮件。电子邮件是否有效(用户地址):
Gcode=''
其他:
确认url=Gcode
发件人地址=“theLaserLab.com”
主题=“订单内容”
body=“附加文件:%s.nc.应从%s厚且尺寸为%s的板材上剪切。”%(文件名、材料、厚度、板材尺寸)
邮件。发送邮件(发件人地址、收件人地址、主题、正文、附件)
您尝试过bytes()方法吗?它将成为一个旁路测试环。