Java- Advance
CDSID: lvishwan
1
LEVEL -3
CDSID: lvishwan
2
7/12/2019
Contents
Send Mail
<script src="C:/js/jquery-3.3.1.js"></script>
<script src="https://smtpjs.com/v3/smtp.js"></script>
<input type="button" onclick="sendEmail_personal()" value="Send" >
<script>
function sendEmail_sharepoint()
{ FROM='viswaa1990@yahoo.com'
TO='viswaa1990@yahoo.com'
BODY='test1'
SUBJECT='test1'
siteurl = _spPageContextInfo.webServerRelativeUrl;
urlTemplate = siteurl + "/_api/SP.Utilities.Utility.SendEmail";
DATA=JSON.stringify({'properties': {'__metadata': {'type': 'SP.Utilities.EmailProperties'},'From': FROM,'To': {'results': [TO]},'Body': BODY,'Subject': SUBJECT}})
$.ajax({contentType: 'application/json',url: urlTemplate,type: "POST",data: DATA,headers: {"Accept": "application/json;odata=verbose","content-type": "application/json;odata=verbose","X-RequestDigest": jQuery("#__REQUESTDIGEST").val()} success: function(data) {alert('Email Sent Successfully')},error: function(err) {alert('Error in sending Email: ' + JSON.stringify(err))} })
}
function sendEmail_personal(){
Email.send({
Host : "smtp.gmail.com",
Username : "visandreams@gmail.com",
Password : "missyou2",
To : 'viswaa1990@yahoo.com',
From : "visandreams@gmail.com",
Subject : "This is the subject",
Body : "And this is the body"
}).then(
message => alert(message)
);}
</script>