Envoi mail accusé réception
J'ai une difficulté pour mettre en place un accusé de réception lorsqu'un utilisateur envoie un formulaire.
J'aimerais que l'utilisateur puisse recevoir un mail pour informer que sa demande a bien été prise en compte.
J'utilise sharepoint 2010 et j'ai un script javascript et une page aspx.
J'ai réussi à mettre en place le formulaire avec l'envoi du mail en interne mais je bloque sur l'envoi d'un mail d'accusé de réception.
Pour mon code javascript :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
function registerTest() {
var path = $(location).attr('href');
var capchallenge = Recaptcha.get_challenge();
var capresponse = Recaptcha.get_response();
try {
var parameters = '{ "url" : "' + cleanJSONString(path) +
...My fields
'", "captchachallenge" : "' + capchallenge +
'", "captcharesponse" : "' + capresponse + '" }';
$.ajax({
type: "POST",
url: '_vti_bin/json/test.svc/registertest',
contentType: "application/json; charset=utf-8",
dataType: 'json',
data: parameters,
success: function (msg) {
registerTestSucceeded(msg);
},
error: registerTestFailed
});
}
catch (e) {
alert('Error invoking service' + e);
}
Recaptcha.reload();
}
function registerTestSucceeded(result) {
alert(result.registertestResult);
}
function registerTestFailed(error) {
alert('An error occured on the server.');
} |
Ma page aspx :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
<div id="content_bottom">
<div id="content_title">
<h1>Register test</h1>
</div>
<div class="submit">
<div class="left">
<input my fields>
</div>
<input my fields>
</div>
<div style="float:left; width:100%;">
<div id="captchadiv"></div>
</div>
<div class="clear"></div>
<div class="submit_container">
<a href="javascript:registerTest();" class="btn orange height_19 submit"><span>
SEND</span></a>
</div>
</div>
</div> |
Mon WebControl :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
using System.Net.Mail;
namespace WCFSharePoint
{
[ServiceContract]
public interface Testservice
{
[OperationContract]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
string registertest(string my fields);
}
[BasicHttpBindingServiceMetadataExchangeEndpointAttribute]
[AspNetCompatibilityRequirementsAttribute(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public class testservice : Testservice
{
public string registertest(string my fields)
{
string mailTest = null;
try
{
mailTest = ConfigurationManager.AppSettings[Constants.APPSETTINGSKEY_MAILTRAINING];
}
catch { }
if (string.IsNullOrEmpty(mailTraining))
{
// -- Use default email set in SharePoint
mailTest = SPAdministrationWebApplication.Local.OutboundMailSenderAddress;
}
try
{
//Check captcha validation
string response = VerifyCaptcha(captchachallenge, captcharesponse);
if (response.ToLowerInvariant().StartsWith("true"))
{
SendEmail(mailTest, string.Format("Registering for testing: {0} (Date: {1})", field1), BuildRegisterTrainingBody(fields2), null);
return "Your request has been sent.";
}
else
{
return "The captcha verification didn't work. Please try again.";
}
}
catch (Exception ex)
{
Logger.LogError(Logger.CATEGORY_WEBSERVICE, string.Format(@"An unexpected error has occurred in the RegisterTest method ({0}))", ex.Message), ex);
throw;
}
}
/// <summary>
/// Writes RegisterTest e-mail body
/// </summary>
private string BuildRegisterTestBody(string my fields)
{
StringBuilder sb = new StringBuilder();
return sb.ToString();
}
#endregion
} |
'aimerais envoyé un mail via le smtp de sharepoint. Je dois reprendre le champs "email" pour l'envoyer à ce destinataire en l'informant la bonne réception de sa demande.
Quelle méthode me conseilleriez-vous ?
Si vous avez des conseils ou des liens ?