Subversion Repositories SmartDukaan

Rev

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

Rev 20375 Rev 21135
Line 6... Line 6...
6
from time import sleep
6
from time import sleep
7
import smtplib
7
import smtplib
8
from email.mime.text import MIMEText
8
from email.mime.text import MIMEText
9
from email.mime.multipart import MIMEMultipart
9
from email.mime.multipart import MIMEMultipart
10
from shop2020.model.v1.catalog.script.AmazonAdvertisingApi import get_best_seller_rank
10
from shop2020.model.v1.catalog.script.AmazonAdvertisingApi import get_best_seller_rank
-
 
11
from shop2020.utils.EmailAttachmentSender import get_attachment_part
-
 
12
from shop2020.utils import EmailAttachmentSender
11
 
13
 
12
con = None
14
con = None
13
parser = optparse.OptionParser()
15
parser = optparse.OptionParser()
14
parser.add_option("-m", "--m", dest="mongoHost",
16
parser.add_option("-m", "--m", dest="mongoHost",
15
                      default="localhost",
17
                      default="localhost",
Line 98... Line 100...
98
        <td style="text-align:center">"""+str(item.rank)+"""</td>
100
        <td style="text-align:center">"""+str(item.rank)+"""</td>
99
        <td style="text-align:center">"""+str(item.title)+"""</td>
101
        <td style="text-align:center">"""+str(item.title)+"""</td>
100
        </tr>"""
102
        </tr>"""
101
    message+="""</tbody></table></body></html>"""
103
    message+="""</tbody></table></body></html>"""
102
    print message
104
    print message
103
    recipients = ['rajneesh.arora@saholic.com','kshitij.sood@saholic.com','chaitnaya.vats@saholic.com','ritesh.chauhan@saholic.com','khushal.bhatia@saholic.com']
105
    recipients = ['kshitij.sood@saholic.com','ritesh.chauhan@saholic.com','aishwarya.singh@saholic.com']
104
    msg = MIMEMultipart()
-
 
105
    msg['Subject'] = "Amazon Best Sellers" + ' - ' + str(datetime.now())
-
 
106
    msg['From'] = ""
-
 
107
    msg['To'] = ",".join(recipients)
-
 
108
    msg.preamble = "Amazon Best Sellers" + ' - ' + str(datetime.now())
-
 
109
    html_msg = MIMEText(message, 'html')
-
 
110
    msg.attach(html_msg)
-
 
111
    
-
 
112
    smtpServer = smtplib.SMTP('localhost')
-
 
113
    smtpServer.set_debuglevel(1)
-
 
114
    sender = 'dtr@shop2020.in'
-
 
115
    try:
-
 
116
        smtpServer.sendmail(sender, recipients, msg.as_string())
106
    EmailAttachmentSender.mail_send_grid("dtr@profitmandi.com","apikey", "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", recipients, "Amazon Best Sellers",message ,[],[],[])              
117
        print "Successfully sent email"
-
 
118
    except:
107
            
119
        print "Error: unable to send email."
-
 
120
            
108
            
121
            
109
            
122
            
110
            
123
def main():
111
def main():
124
    getBestSellers("1389432031","Mobiles")
112
    getBestSellers("1389432031","Mobiles")