$.net
$.net
represents the network namespace with its fields.
Overview
Sample Usage
Note
Requires a running mail server. If mailConfig
is not set the api defaults to a local mail server.
For more information please take a look here.
let net = $.net;
// Create a mail Object
let mail = new net.Mail({
sender: {address: "sender@sap.com"},
to: [{ name: "John Doe", address: "john.doe@sap.com"}, {name: "Jane Doe", address: "jane.doe@sap.com"}],
cc: [{address: "cc1@sap.com"}, {address: "cc2@sap.com"}],
bcc: [{ name: "Jonnie Doe", address: "jonnie.doe@sap.com"}],
subject: "subject",
subjectEncoding: "UTF-8",
parts: [ new net.Mail.Part({
type: net.Mail.Part.TYPE_TEXT,
text: "The body of the mail.",
contentType: "text/plain",
encoding: "UTF-8",
})]
});
// Set mail server configuration.
let mailConfig = {
"mail.user": "<your-user>",
"mail.password": "<your-password>",
"mail.transport.protocol": "smtps",
"mail.smtps.host": "<your-mail-provider-host>",
"mail.smtps.port": "465",
"mail.smtps.auth": "true"
};
let smtp = new net.SMTPConnection(mailConfig);
// Send the mail Object with SMPT
smtp.send(mail);
// Send the mail Object from the built-in mail send method.
let returnValue = mail.send(mailConfig);
$.response.setBody(JSON.stringify(returnValue));
Classes
Classes |
Description |
Mail |
Class for constructing and sending multipart emails. |
SMTPConnection |
Class for sending $.net.Mail objects via SMTP connection. |
Destination |
Contains metadata, for example, host name and port number. |
Properties
Name |
Description |
Type |
http |
Provides access to the http API. |
$.net.http |
HTTP constants for methods
Name |
Description |
Type |
Default |
OPTIONS |
HTTP Method OPTIONS. |
number |
0 |
GET |
HTTP Method GET. |
number |
1 |
HEAD |
HTTP Method HEAD. |
number |
2 |
POST |
HTTP Method POST. |
number |
3 |
PUT |
HTTP Method PUT. |
number |
4 |
DEL |
HTTP Method DEL. |
number |
5 |
TRACE |
HTTP Method TRACE. |
number |
6 |
CONNECT |
HTTP Method CONNECT. |
number |
7 |
PATCH |
HTTP Method PATCH. |
number |
8 |
Example
let constantVal = $.net.http.OPTIONS;
HTTP constants for status codes
Name |
Type |
Default |
CONTINUE |
number |
100 |
SWITCH_PROTOCOL |
number |
101 |
OK |
number |
200 |
CREATED |
number |
201 |
ACCEPTED |
number |
202 |
NON_AUTHORITATIVE |
number |
203 |
NO_CONTENT |
number |
204 |
RESET_CONTENT |
number |
205 |
PARTIAL_CONTENT |
number |
206 |
MULTIPLE_CHOICES |
number |
300 |
MOVED_PERMANENTLY |
number |
301 |
FOUND |
number |
302 |
SEE_OTHER |
number |
303 |
NOT_MODIFIED |
number |
304 |
USE_PROXY |
number |
305 |
TEMPORARY_REDIRECT |
number |
307 |
BAD_REQUEST |
number |
400 |
UNAUTHORIZED |
number |
401 |
PAYMENT_REQUIRED |
number |
402 |
FORBIDDEN |
number |
403 |
NOT_FOUND |
number |
404 |
METHOD_NOT_ALLOWED |
number |
405 |
NOT_ACCEPTABLE |
number |
406 |
PROXY_AUTH_REQUIRED |
number |
407 |
REQUEST_TIMEOUT |
number |
408 |
CONFLICT |
number |
409 |
GONE |
number |
410 |
LENGTH_REQUIRED |
number |
411 |
PRECONDITION_FAILED |
number |
412 |
REQUEST_ENTITY_TOO_LARGE |
number |
413 |
REQUEST_URI_TOO_LONG |
number |
414 |
UNSUPPORTED_MEDIA_TYPE |
number |
415 |
REQUESTED_RANGE_NOT_SATISFIABLE |
number |
416 |
EXPECTATION_FAILED |
number |
417 |
INTERNAL_SERVER_ERROR |
number |
500 |
NOT_YET_IMPLEMENTED |
number |
501 |
BAD_GATEWAY |
number |
502 |
SERVICE_UNAVAILABLE |
number |
503 |
GATEWAY_TIMEOUT |
number |
504 |
HTTP_VERSION_NOT_SUPPORTED |
number |
505 |
Example
let statusCode = $.net.http.CONTINUE;