Subversion Repositories SmartDukaan

Rev

Rev 14047 | Rev 14054 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 14047 Rev 14048
Line 206... Line 206...
206
    filename = "/tmp/deal-data-user-specific"+str(datetime.now())+".xls" 
206
    filename = "/tmp/deal-data-user-specific"+str(datetime.now())+".xls" 
207
    wbk.save(filename)
207
    wbk.save(filename)
208
    smtpServer = smtplib.SMTP('localhost')
208
    smtpServer = smtplib.SMTP('localhost')
209
    #smtpServer.set_debuglevel(1)
209
    #smtpServer.set_debuglevel(1)
210
    sender = 'dtr@shop2020.in'
210
    sender = 'dtr@shop2020.in'
211
    recipients = ['kshitij.sood@saholic.com']
211
    #recipients = ['kshitij.sood@saholic.com']
212
    msg = MIMEMultipart()
212
    msg = MIMEMultipart()
213
    msg['Subject'] = "DTR Deals data (UserOnly) UserId - "+str(userId)+"" + ' - ' + str(datetime.now())
213
    msg['Subject'] = "DTR Deals data (UserOnly) UserId - "+str(userId)+"" + ' - ' + str(datetime.now())
214
    msg['From'] = sender
214
    msg['From'] = sender
215
    #recipients = ['rajneesh.arora@saholic.com','kshitij.sood@saholic.com']
215
    recipients = ['rajneesh.arora@saholic.com','kshitij.sood@saholic.com']
216
    msg['To'] = ",".join(recipients)
216
    msg['To'] = ",".join(recipients)
217
    fileMsg = email.mime.base.MIMEBase('application','vnd.ms-excel')
217
    fileMsg = email.mime.base.MIMEBase('application','vnd.ms-excel')
218
    fileMsg.set_payload(file(filename).read())
218
    fileMsg.set_payload(file(filename).read())
219
    email.encoders.encode_base64(fileMsg)
219
    email.encoders.encode_base64(fileMsg)
220
    fileMsg.add_header('Content-Disposition','attachment;filename=Deal_Sheet_Dtr.xls')
220
    fileMsg.add_header('Content-Disposition','attachment;filename=User_Deal_Sheet_Dtr.xls')
221
    msg.attach(fileMsg)
221
    msg.attach(fileMsg)
222
    try:
222
    try:
223
        smtpServer.sendmail(sender, recipients, msg.as_string())
223
        smtpServer.sendmail(sender, recipients, msg.as_string())
224
        print "Successfully sent email"
224
        print "Successfully sent email"
225
    except:
225
    except: