Can I use SPServices to send e-mail?

Aug 21, 2010 at 9:38 PM
Edited Aug 21, 2010 at 9:56 PM

Hi,

I am working on a SharePoint 2007 intranet project with the following restrictions:

1. Cannot use SharePoint Designer.

2. Cannot use any type of "server side" code (i.e. DLL in the GAC, WSP, etc.)

In other words, I can only use "client side" code (i.e. HTML, jQuery, JavaScript embedded in a Content Editor Web Part).

Requirements

1. Capture some basic user related info such as First Name, Last Name, Contact Phone, Employee ID, etc.

2. Send an e-mail cotaining the above user info, to a designated e-mail address.

I am planning to use a SharePoint "Content Editor Web Part" (CEWP) to render the fields to capture First Name, Last Name, Contact Phone, etc. The fields will be defined as HTML <input> type controls in the CEWP. I will also have a <input type="button"> control that will serve as the "Submit" button.

When the user clicks on the "Submit" button, I need to gather all the values entered in the fields, put them in an e-mail and send it to an e-mail address.

The SMTP server is configured on the SharePoint site.

Is it possible to use the SPServices library to send e-mail? Not just "mailto" type of e-mail which means that a new Outlook e-mail message is composed. I need the e-mail to be sent automatically to the designated e-mail address, when the "Submit" button is clicked. Just wondering if there is a way using SPServices to leverage either the SPUtility.SendEmail or System.Net.Mail to send the e-mail. I looked at the MOSS Web Services, but did not see any e-mail related methods.

Please let me know.

Thanks a lot. I appreciate any suggestions or other "client side" solutions that I may have overlooked.

Kiran

 

Coordinator
Aug 21, 2010 at 10:06 PM

Kiran:

I don't think that SPServices is going to help you around this impossible set of restrictions. There's no way I can think of that you can use the SharePoint Web Services to send an email. You might be ably to leverage something else with jQuery and AJAX, though.

M.

Coordinator
Aug 22, 2010 at 12:39 AM

Kiran,

As Marc mentioned, SPServices is probably not going to help you send email. Sending email from the client side browser without passing it through some sort of a server side script is going to be plagued with security risks as it won't be able to authenticate users or verify credentials to send. If your environment is locked down as much as it is where they don't want you even using SharePoint Designer, I would imagine they'd have a fit a the thought of unauthenticated email flowing through their mail servers!

Mike

Aug 23, 2010 at 2:01 AM

Mark and Mike - Thanks for your responses and for the validation that sending e-mail (using a purely client side solution) is not possible. 

Mark - I will look into jQuery/AJAX option like you were suggesting. If that does not work, I may just fall back to the "mailto" solution.

Thanks again.

Best regards,
Kiran

Aug 23, 2010 at 5:33 PM

I do have a suggestion that might work. The operative word here is might! If you can at least setup alerts on a list, then you can "trick" send an email by setting up an alert for the user when new items are added to the list. The add the items as planned using the webservices. I have tested that this does work for what I do, but your mileage may vary!!

This does assume that the email you need to send to is a user in this Sharepoint site.

Dan

Coordinator
Aug 23, 2010 at 7:57 PM

Well Dan... that's a little concept I'm going to file away for a rainy day... you never know when that method might work in a pinch ;-)