Subversion Repositories SmartDukaan

Rev

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

Rev 15463 Rev 15480
Line 3... Line 3...
3
 
3
 
4
@author: amit
4
@author: amit
5
'''
5
'''
6
 
6
 
7
from datetime import datetime, timedelta, date
7
from datetime import datetime, timedelta, date
-
 
8
from email import encoders
-
 
9
from email.mime.base import MIMEBase
-
 
10
from email.mime.multipart import MIMEMultipart
8
from dtr.reports.affiliatereco import sendmail
11
from email.mime.text import MIMEText
9
import MySQLdb
12
import MySQLdb
10
import copy
13
import copy
-
 
14
import smtplib
11
import xlwt
15
import xlwt
12
 
16
 
-
 
17
SENDER = "adwords@shop2020.in"
-
 
18
PASSWORD = "adwords_shop2020"
-
 
19
SUBJECT = "CRM Outbound Report for " + str(date.today() - timedelta(days=1))
-
 
20
SMTP_SERVER = "smtp.gmail.com"
-
 
21
SMTP_PORT = 587  
13
 
22
 
14
date_format = xlwt.XFStyle()
23
date_format = xlwt.XFStyle()
15
date_format.num_format_str = 'dd/mm/yyyy'
24
date_format.num_format_str = 'dd/mm/yyyy'
16
 
25
 
17
datetime_format = xlwt.XFStyle()
26
datetime_format = xlwt.XFStyle()
Line 405... Line 414...
405
    followupSheet = workbook.add_sheet("Followup Call Summary")
414
    followupSheet = workbook.add_sheet("Followup Call Summary")
406
    setWorksheetTemplate(freshSheet, followupSheet)
415
    setWorksheetTemplate(freshSheet, followupSheet)
407
    populateFreshSheet(freshSheet)
416
    populateFreshSheet(freshSheet)
408
    populateFollowupSheet(followupSheet)
417
    populateFollowupSheet(followupSheet)
409
    workbook.save("crmacquisition.xls")
418
    workbook.save("crmacquisition.xls")
410
    sendmail(["amit.gupta@shop2020.in", "rajneesh.arora@saholic.com", "amit.sirohi@shop2020.in"], "", "CRM Acquision Report", "crmacquisition.xls")        
419
    sendmail(["amit.gupta@shop2020.in", "rajneesh.arora@saholic.com", "amit.sirohi@shop2020.in"], "", "CRM Acquision Report", "crmacquisition.xls")
-
 
420
    
-
 
421
def sendmail(email, message, title, *varargs):
-
 
422
    if email == "":
-
 
423
        return
-
 
424
    mailServer = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
-
 
425
    mailServer.ehlo()
-
 
426
    mailServer.starttls()
-
 
427
    mailServer.ehlo()
-
 
428
    
-
 
429
    # Create the container (outer) email message.
-
 
430
    msg = MIMEMultipart()
-
 
431
    msg['Subject'] = title
-
 
432
    msg.preamble = title
-
 
433
    html_msg = MIMEText(message, 'html')
-
 
434
    msg.attach(html_msg)
-
 
435
    
-
 
436
    #snapdeal more to be added here
-
 
437
    for fileName in varargs:
-
 
438
        snapdeal = MIMEBase('application', 'vnd.ms-excel')
-
 
439
        snapdeal.set_payload(file(fileName).read())
-
 
440
        encoders.encode_base64(snapdeal)
-
 
441
        snapdeal.add_header('Content-Disposition', 'attachment;filename=' + fileName)
-
 
442
        msg.attach(snapdeal)
-
 
443
 
-
 
444
 
-
 
445
    email.append('amit.gupta@shop2020.in')
-
 
446
    MAILTO = email 
-
 
447
    mailServer.login(SENDER, PASSWORD)
-
 
448
    mailServer.sendmail(PASSWORD, MAILTO, msg.as_string())        
-
 
449
 
411
def main():
450
def main():
412
    generateCrmAcquisitionReport()
451
    generateCrmAcquisitionReport()
413
 
452
 
414
if __name__ == '__main__':
453
if __name__ == '__main__':
415
    main()
454
    main()