2009/10/6 StevenC <spchu...@gmail.com>: > > Hey all. > > I have been set a massive project and one of the fundimentals is to > create a Mailbox in Microsoft Exchange 2007. My choice of language is > going to be Django/Python rather than PHP because i want to move away > from PHP. > > Soo, my question to everyone is.. Does anyone know if you can directly > create Mailboxes via Django or in a worst case, can you run DOS > commands using Django. This was PowerShell commands could be > constructed and fed to the server to process.
Ah, combining my 2 favourite scripting languages :) I doubt you can create mailboxes directly from Python, and even if you could, I wouldn't do it because it isn't the supported way. I'd just get Python to call a DOS command (assuming you're running this on a Windows box). First off, write a script that does what you need to create the Exchange mailbox - make sure it is written to accept parameters for things like user identity, mailbox size etc. (the 'help new-mailbox' command will give you more info on parameters; alternatively consult the Exchange reference). Make the script return an exit code to indicate if it worked or not. Call this newMailbox.ps1. Then using python, import the subprocess module, and use the call method in that to execute the following command: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -command ". 'C:\path\to\the\script\newMailbox.ps1' <parameters>" (The PSConsoleFile parameter is needed so PowerShell loads the Exchange cmdlets. Replace <parameters> with the necessary parameters.) One concern is that depending on how long that script takes to work, the web request may time out. From memory, it shouldn't, but it might be something to consider. HTH, Sam --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---