def sendNote(self, sendTo, replyToAdr, headertext, bodyText, lnkAdr): try: smtpServer = WebConfigurationManager.AppSettings['smtpServer'] smtpUser = WebConfigurationManager.AppSettings['smtpUser'] smtpPwd = WebConfigurationManager.AppSettings['smtpPwd'] fromAddr = WebConfigurationManager.AppSettings['cptchSndrAdrss'] # load the template for the HTML-mail tmpltPath = self.Page.Server.MapPath( WebConfigurationManager.AppSettings['JobTrialHtmlBody']) self.log.w2lgDvlp('ItemJobMsg->sendNote = ' + tmpltPath) file = open(tmpltPath) mailBody = file.read() file.close() #Create A New SmtpClient Object mailClient = SmtpClient(smtpServer, 25) mailClient.EnableSsl = True mailCred = NetworkCredential() mailCred.UserName = smtpUser mailCred.Password = smtpPwd mailClient.Credentials = mailCred msg = MailMessage() msg.From = MailAddress(fromAddr) msg.ReplyTo = MailAddress(replyToAdr) msg.To.Add(MailAddress(sendTo)) msg.SubjectEncoding = System.Text.Encoding.UTF8 msg.BodyEncoding = System.Text.Encoding.UTF8 msg.IsBodyHtml = True mailSubj = self.ui.getCtrl('msg_mailSubject').Text + headertext mailBody = mailBody.replace('###header###', headertext) mailBody = mailBody.replace('###body###', bodyText) mailBody = mailBody.replace('###link###', lnkAdr) self.log.w2lgDvlp('ItemJobMsg.sendNote link-address : ' + lnkAdr) msg.Subject = mailSubj msg.Body = mailBody mailClient.Send(msg) except Exception, e: self.log.w2lgError(traceback.format_exc())
def sendNote( self, sendTo, replyToAdr, headertext, bodyText, lnkAdr ): try: smtpServer = WebConfigurationManager.AppSettings['smtpServer'] smtpUser = WebConfigurationManager.AppSettings['smtpUser'] smtpPwd = WebConfigurationManager.AppSettings['smtpPwd'] fromAddr = WebConfigurationManager.AppSettings['cptchSndrAdrss'] # load the template for the HTML-mail tmpltPath = self.Page.Server.MapPath( WebConfigurationManager.AppSettings['JobTrialHtmlBody'] ) self.log.w2lgDvlp('ItemJobMsg->sendNote = ' + tmpltPath ) file = open(tmpltPath) mailBody = file.read() file.close() #Create A New SmtpClient Object mailClient = SmtpClient(smtpServer,25) mailClient.EnableSsl = True mailCred = NetworkCredential() mailCred.UserName = smtpUser mailCred.Password = smtpPwd mailClient.Credentials = mailCred msg = MailMessage() msg.From = MailAddress(fromAddr) msg.ReplyTo = MailAddress(replyToAdr) msg.To.Add( MailAddress( sendTo ) ) msg.SubjectEncoding = System.Text.Encoding.UTF8 msg.BodyEncoding = System.Text.Encoding.UTF8 msg.IsBodyHtml = True mailSubj = self.ui.getCtrl('msg_mailSubject').Text + headertext mailBody = mailBody.replace('###header###' , headertext ) mailBody = mailBody.replace('###body###' , bodyText ) mailBody = mailBody.replace('###link###' , lnkAdr ) self.log.w2lgDvlp('ItemJobMsg.sendNote link-address : ' + lnkAdr ) msg.Subject = mailSubj msg.Body = mailBody mailClient.Send(msg) except Exception,e: self.log.w2lgError(traceback.format_exc())
def sendToNejobaTeam(): try: # get the textdata for mail tool.ui.getCtrlTree( Page.Master ) mailSubj = tool.ui.getCtrl('txbHeader').Text mailBody = tool.ui.getCtrl('txtMain').Text smtpServer = WebConfigurationManager.AppSettings['smtpServer'] smtpUser = WebConfigurationManager.AppSettings['smtpUser'] smtpPwd = WebConfigurationManager.AppSettings['smtpPwd'] fromAddr = WebConfigurationManager.AppSettings['cptchSndrAdrss'] #Create A New SmtpClient Object mailClient = SmtpClient(smtpServer,25) mailClient.EnableSsl = True mailCred = NetworkCredential() mailCred.UserName = smtpUser mailCred.Password = smtpPwd mailClient.Credentials = mailCred sendTo = '*****@*****.**' msg = MailMessage() msg.From = MailAddress('*****@*****.**') msg.ReplyTo = MailAddress('*****@*****.**') msg.To.Add( MailAddress( sendTo ) ) msg.SubjectEncoding = System.Text.Encoding.UTF8 msg.BodyEncoding = System.Text.Encoding.UTF8 msg.IsBodyHtml = False msg.Subject = mailSubj msg.Body = mailBody mailClient.Send(msg) # toogle divs to show message was send tool.ui.getCtrl('mailSendSuccesfullyMessage').Visible = True tool.ui.getCtrl('divEditArea').Visible = False except Exception,e: tool.log.w2lgError(traceback.format_exc())
def sendToNejobaTeam(): try: # get the textdata for mail tool.ui.getCtrlTree(Page.Master) mailSubj = tool.ui.getCtrl('txbHeader').Text mailBody = tool.ui.getCtrl('txtMain').Text smtpServer = WebConfigurationManager.AppSettings['smtpServer'] smtpUser = WebConfigurationManager.AppSettings['smtpUser'] smtpPwd = WebConfigurationManager.AppSettings['smtpPwd'] fromAddr = WebConfigurationManager.AppSettings['cptchSndrAdrss'] #Create A New SmtpClient Object mailClient = SmtpClient(smtpServer, 25) mailClient.EnableSsl = True mailCred = NetworkCredential() mailCred.UserName = smtpUser mailCred.Password = smtpPwd mailClient.Credentials = mailCred sendTo = '*****@*****.**' msg = MailMessage() msg.From = MailAddress('*****@*****.**') msg.ReplyTo = MailAddress('*****@*****.**') msg.To.Add(MailAddress(sendTo)) msg.SubjectEncoding = System.Text.Encoding.UTF8 msg.BodyEncoding = System.Text.Encoding.UTF8 msg.IsBodyHtml = False msg.Subject = mailSubj msg.Body = mailBody mailClient.Send(msg) # toogle divs to show message was send tool.ui.getCtrl('mailSendSuccesfullyMessage').Visible = True tool.ui.getCtrl('divEditArea').Visible = False except Exception, e: tool.log.w2lgError(traceback.format_exc())