Example #1
0
def SendMail(sender, msg, subject, filenmame=None):

    outlook_config_data = cs.readConfig('outlook_mail')
    emailId = outlook_config_data.get('emailId')
    password = outlook_config_data.get('emailPassword')

    if emailId == None or password == None:
        cs.warn('unable to retrive mail cred')
        cs.reConfig('outlook_mail')
        return SendMail(sender, msg, subject, filenmame)

    authenticiation = (emailId, password)
    m = Message(auth=authenticiation)
    m.setRecipients(sender)
    m.setSubject(subject)
    m.setBodyHTML(msg)
    m.setSenderName()

    if filenmame:
        att = Attachment(path=filenmame)
        m.attachments.append(att)

    mailSendStatus = m.sendMessage()

    return mailSendStatus