[python-win32] name not defined

Dahlstrom, Roger rdahlstrom at directedge.com
Wed Jul 30 13:36:21 CEST 2008


That seems like a roundabout way to send an email.
 
def sendEmail(toe, frome, subject, body):
    import smtplib
    headers = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (frome, toe, subject)
    message = headers + body
    mailsvr = "MyMailServer"
    mailServer = smtplib.SMTP(mailsvr)
    mailServer.sendmail(frome, toe, message)
    mailServer.quit()
 
 
sendEmail(me at somewhere.com <mailto:me at somewhere.com> , you at somewhere.com <mailto:you at somewhere.com> , "test subject", "Body")

________________________________

From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of kNish
Sent: Wednesday, July 30, 2008 7:29 AM
To: python-win32 at python.org
Subject: [python-win32] name not defined


Hi,

        I am using the following code to send mail from a open window in maya application. This gives me following error. I think it says that A2 is not
created. What is a possible way to have this code send a mail.


BRgds,

kNish

# Error: name 'A2' is not defined
# Traceback (most recent call last):
#   File "<maya console>", line 1, in <module>
# NameError: name 'A2' is not defined # 


import maya.cmds as cmds
import smtplib
import os


class pMailmsg:
    "send message modules"
    def __init__(self):
        self.fUser = os.getenv("USERNAME")
        self.tUser = "ppro at eyeqube.com"
        self.conts = ""

    def pSendmsg(self,fromUser,toUser,contents):
        fU = cmds.textField(fromUser, query = True, text = True)
        tU = cmds.textField(toUser, query = True, text = True)
        co = cmds.textField(contents, query = True, text = True)
        cServer = smtplib.SMTP("xxx.xxx.x.x:xx")
        cServer.sendmail = (fU, tU, co)
        cServer.quit()
        
    def pShowWindow(self):
        fromWho = self.fUser
        toWhom = self.tUser
        window = cmds.window(width=150, height = 150)
        form   = cmds.formLayout(numberOfDivisions = 200)
        fromText = cmds.text(label='From : ')
        fromUser = cmds.textField(width = 250)

        toText   = cmds.text(label = 'To : ')
        toUser   = cmds.textField(width = 250)
        subjectText = cmds.text(label = 'Subject : ')
        subject  = cmds.textField(width = 250)
        contentsText = cmds.text(label = 'Contents : ')
        contents = cmds.scrollField(editable = True, wordWrap = True, width = 250, height = 100)
        submit   = cmds.button(label = 'Send Mail', command = ('pSendmsg()'))

        cmds.textField(fromUser, edit = True, text = (fromWho + '@eyeqube.com'), enable = False)
        cmds.textField(toUser, edit = True, text = toWhom, enable = False)
        cmds.textField(subject, edit = True,enable = False)

        cmds.formLayout( form, edit=True, attachForm=[(fromText, 'left', 5), (fromText, 'top', 5), (toText, 'left', 15), (fromUser, 'top', 5), (contents,
'left', 5), (submit, 'left', 165) ], 
        attachControl=[(toText, 'top', 15, fromText), (subjectText, 'top', 25, toText), (contentsText, 'top',25,subjectText), (fromUser, 'left', 15, fromText),
(toUser, 'top', 15, fromUser), (toUser, 'left', 15, toText), (subject, 'top', 15, toUser), (subject, 'left', 10, subjectText), (contents, 'top', 15, subject),
(contents, 'left', 5, contentsText), (submit, 'top', 15, contents)])
        cmds.showWindow( window )
        
        
c = pMailmsg()
c.pShowWindow()



DISCLAIMER:
This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and
may contain legally privileged and/or confidential information. If you are not the intended recipient
of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and 
any attachments thereto, is strictly prohibited. If you have received this in error, please immediately notify 
me and permanently delete the original and any copy of any e-mail and any printout thereof. 
E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept 
liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission.

NOTICE REGARDING PRIVACY AND CONFIDENTIALITY
Direct Edge ECN LLC may, at its discretion, monitor and review the content of all e-mail communications.

www.directedge.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20080730/652c10e3/attachment.htm>


More information about the python-win32 mailing list