"Add email" script for hsphere

wotech

Perch
Hi all,

I've been researching this hsphere xml api. I'm curious if anyone already has a working script (php, asp, .net, perl, pascal, qbasic (just kidding on those last 2)) that would add email address(es) without having to login, and go through the standard procedure.

My ultimate goal is to provide something for one of my clients where they can add email addresses for their employees without me having to let them login to an hsphere account.

Any suggestions/direction would be fantastic!! Thanx!

-ross
 
yes this is quite easy to do i have used the envelope and have a whole secondary control panel running off hsphere

ive programmed in asp, and seems to be working quite well i have it all built on functions like to add a email i use AddMailBox(address,Password,)

then uses my bilt in functions to send the request.
 
interested in selling it? or just being a really cool person and emailing it to me? :D

I currently have a portal system for the client. So whenever they get a new employee, an administrator logs in to the portal and adds the user so they have access to the portal. I would just like to add a little script that would also create the email address for the new user at the same time.

what do you think?
 
Pretty easy once you get the hang of it. Thanks to Emagine I was able to run a couple of the API functions.

I never tried the add email feature but shouldn't be too complicated. I can send you the AuthToken with the POST request if you wish (it's PHP).
 
Hi Emagine,

I am in the same suitation. Can you please email me the code?

Thanks,
Lokesh.
 
here is my envelope in ASP

Function AddMailBox(strEmailAddress, strDomain, strPassword, strDescription, strUsername, intAccountID)

' authenticate the user with admin access
strAddMailBoxEnvelope = _

"<ns1:addMailbox soap:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/"" xmlns:ns1=""MailServices"">" & _
"<at href=""#id0""/>" & _
"<email xsi:type=""xsd:string"">" & strEmailAddress &"</email>" & _
"<domain xsi:type=""xsd:string"">" & strDomain &"</domain>" & _
"<password xsi:type=""xsd:string"">" & strPassword &"</password>" & _
"<description xsi:type=""xsd:string"">" & strDescription &"</description>" & _
"</ns1:addMailbox>" & _
"<multiRef id=""id0"" soap:root=""0"" soap:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/"" xsi:type=""ns2:AuthToken"" xmlns:soap=""http://schemas.xmlsoap.org/soap/encoding/"" xmlns:ns2=""urn:MailServices"">" & _
"<accountId xsi:type=""xsd:int"">0</accountId>" & _
"<login xsi:type=""xsd:string"">" & strAdminUsername &"</login>" & _
"<password xsi:type=""xsd:string"">"& strAdminPassword &"</password>" & _
"" & vbCrLF & "<role href=""#id1""/>" & _
"" & vbCrLF & "</multiRef>" & _
"" & vbCrLF & "<multiRef id=""id1"" soap:root=""0"" soap:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/"" xsi:type=""ns3:Role"" xmlns:ns3=""urn:MailServices"" xmlns:soap=""http://schemas.xmlsoap.org/soap/encoding/"">" & _
"" & vbCrLF & "<accountId xsi:type=""xsd:int"">" & intAccountID &"</accountId>" & _
"" & vbCrLF & "<login xsi:type=""xsd:string"">" & strUsername &"</login>" & _
"" & vbCrLF & "</multiRef>"


strAddMailBoxService = "MailServices"


AddMailBox = trim(GetSoapReturn(strAddMailBoxEnvelope, strAddMailBoxService))

End Function


ive used a function to create that envelope and i have a envelope to send the Envelopes to Hsphere

the above is a reseller level envelope, ie resellers can change customers/add emails
 
OK,
I'm trying to get the API to work. I copy and pasted the script emagine posted previously that gets the User contact info.

At first I was getting a 403 error (forbidden), but Jodo took care of that. Now I'm getting a 501 error and it says that I can't post; here's the exact error:

HTTP Status 501 - Method post is not defined in RFC 2068 and is not supported by the Servlet API


Jodo says it's not a problem with their stuff.
Anyone have any ideas?

Thanks a bunch in advance!!!

-ross
 
here's the exact code I have in the ASP page:

Code:
<%
Function GetSoapReturn(strEnvelope, strService)

Dim objHTTP
Dim strReturn


Set objHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")

strSendingEnvelope = " <soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""> " & _
"<soap:Header > </soap:Header> " & _
" <soap:Body>" & _
"" & strEnvelope & "" & _
"</soap:Body>" & _
"</soap:Envelope>"

'Set up to post to our local server
objHTTP.open "post", "http://cp.cpdomainname.com/psoft/servlet/" & strService &".jws", False

'Set a standard SOAP/ XML header for the content-type
objHTTP.setRequestHeader "Content-Type", "text/xml"

'Set a header for the method to be called
objHTTP.setRequestHeader "SOAPAction", "urn:" & strService &""

'Make the SOAP call
objHTTP.send strSendingEnvelope

'Get the return envelope
strReturn = objHTTP.responseText


set objHTTP = Nothing


GetSoapReturn = strReturn

End Function



' get contact info for the user
strContactEnvelope = _

" <ns1:getContactInfo xmlns:ns1=""UserServices"">" & _
" <at href=""#id0""/>" & _
" </ns1:getContactInfo>" & _
" <multiRef id=""id0"" soap:root=""0"" xsi:type=""ns2:AuthToken"" xmlns:ns2=""urn:UserServices"">" & _
" <accountId xsi:type=""xsd:int"">0</accountId>" & _
" <login xsi:type=""xsd:string"">adminUsername</login>" & _
" <password xsi:type=""xsd:string"">adminPassword</password>" & _
"<role href=""#id1""/>" & _
"</multiRef>" & _
"<multiRef id=""id1"" soap:root=""0"" soap:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/"" xsi:type=""ns3:Role"" xmlns:ns3=""urn:UserServices"" xmlns:soap=""http://schemas.xmlsoap.org/soap/encoding/"">" & _
"<accountId xsi:type=""xsd:int"">0</accountId>" & _
"<login xsi:type=""xsd:string"">EndUserUsername</login>" & _
"</multiRef>"


strContactService = "UserServices"


response.write(GetSoapReturn(strContactEnvelope,strContactService))
%>
 
Back
Top