[Python.NET] Unable to import library imaplib

Kris Beyers kris_beyers at hotmail.com
Fri Apr 13 10:45:53 CEST 2007

I changed the version to 2.44, but the problem remains.
Meanwhile I found another solution to communicate directly from C# to an IMAP server with a very nice freeware library. It also includes some other protocol communication like pop3, smtp, Auth_HttpDigest, dns, ftp, http, icmp, io, log, mime, nntp, sdp and sip.
If you are interested, you can find my writings here http://www.lumisoft.ee/Forum/default.aspx?g=posts&t=98
The example there uses following library http://www.lumisoft.ee/lsWWW/ENG/Products/WEB_Mail/webmail_index_eng.aspx?type=download

Date: Wed, 11 Apr 2007 11:18:24 -0400Subject: Re: [Python.NET] Unable to import library imaplibFrom: brian.lloyd at revolution.comTo: kris_beyers at hotmail.com; dvpdiner2 at yahoo.comCC: pythondotnet at python.org
Note that the latest PythonNet is built for and includes 2.4, not 2.5, unless you’ve built your own version.That probably means that pythonnet is looking at the PYTHONPATH for 2.4, which probably doesn’t have imaplib installed.I’d suggest making sure to install imaplib in the site-packages used by your PythonNet/2.4 installation...-BrianOn 4/11/07 5:16 AM, "Kris Beyers" <kris_beyers at hotmail.com> wrote:
Hi I can import CLR, but not imaplib. Although imaplib is part of the standard python library, and I suppose I didn't need CLR.I also tried different combinations of case of the word "imaplib", since the import statement is case sensitive.Currently I have the latest Python version 25, and installed the latest PythonNet afterwards (PythonNet 1.0 release candidate 2).Also tried to include the path to the C:\Python25\Lib in the systemvariable PATH, where imaplib.py resides. Furthermore I included C:\Program Files\PythonNet in the same systemvariable, but that's nog part of the problem I guess. Regards,Kris

Date: Tue, 10 Apr 2007 19:39:43 -0700From: dvpdiner2 at yahoo.comSubject: Re: [Python.NET] Unable to import library imaplibTo: kris_beyers at hotmail.comCC: pythondotnet at python.orgDid you use (in Python)>>> import clrto import the Common Language Runtime and support .NET assemblies?  <http://www.urulive.com/blog/> Uru Live IRC Chat: unreal.JustIRC.net #uru----- Original Message ----From: Kris Beyers <kris_beyers at hotmail.com>To: pythondotnet at python.orgSent: Tuesday, April 10, 2007 1:31:35 PMSubject: [Python.NET] Unable to import library imaplibHi I'm trying to make a python script (which would be called from a C# application) and communicates with an IMAP server.Passing variables from C# to python and back is no problem, but when I type "import imaplib" on top of the python script to support IMAP, the script fails to run at line with following code: "func.Invoke(arguments)". Showing error message in the C# developer: "<null reference>". I also tried to call PythonEngine.ImportModule("imaplib") first, but no change.Is there a way to import the library? Thank you in advance. Tip: Just found out about an amazing C# developer http://www.sharpdevelop.net <http://www.sharpdevelop.net/>  (open source) Regards,Kris C#***try { string imapUser = "kris"; string imapPassword = "a password";     PythonEngine.Initialize();     PyObject[] arguments = new PyObject[2]; arguments[0] = PyObject.FromManagedObject(imapUser); arguments[1] = PyObject.FromManagedObject(imapPassword);     PyObject pyportal = PythonEngine.ImportModule("PyPortal"); PyObject func = pyportal.GetAttr("invoker");     PyObject result = func.Invoke(arguments); this.label1.Text = result.ToString();} catch (Exception err) { this.label1.Text = err.Message.ToString();} The file PyPortal.py***************import imaplib                      #  <-- causes errordef invoker(imapUser, imapPassword):    messages = []    M = imaplib.IMAP4('imap.next.mail.yahoo.com')    M.login(imapUser, imapPassword)    M.select()    typ, data = M.search(None, 'ALL')    for num in data[0].split():        typ, data = M.fetch(num, '(RFC822)')        messages.append('Message %s\n%s\n' % (num, data[0][1]))    M.close()    M.logout()    return '<delimiter>'.join(messages)  het ultieme online mailprogramma! Ontdek Windows Live Hotmail, <http://get.live.com/mail/overview>  _________________________________________________Python.NET mailing list - PythonDotNet at python.orghttp://mail.python.org/mailman/listinfo/pythondotnet

Now you can have a huge leap forward in email: get the new Yahoo! Mail. <http://us.rd.yahoo.com/evt=40705/*http://mrd.mail.yahoo.com/try_beta?.intl=ca>  

het ultieme online mailprogramma! Ontdek Windows Live Hotmail, <http://get.live.com/mail/overview> 

_________________________________________________Python.NET mailing list - PythonDotNet at python.orghttp://mail.python.org/mailman/listinfo/pythondotnet
Ontdek Windows Live Hotmail, het ultieme online mailprogramma!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/pythondotnet/attachments/20070413/c0c59b17/attachment.html 

More information about the PythonDotNet mailing list