| Requires any of the roles: | Client, Admin, Partner |
| POST | /communication/sendmail | Sends an email |
|---|
<?php namespace dtos;
use DateTime;
use Exception;
use DateInterval;
use JsonSerializable;
use ServiceStack\{IReturn,IReturnVoid,IGet,IPost,IPut,IDelete,IPatch,IMeta,IHasSessionId,IHasBearerToken,IHasVersion};
use ServiceStack\{ICrud,ICreateDb,IUpdateDb,IPatchDb,IDeleteDb,ISaveDb,AuditBase,QueryDb,QueryDb2,QueryData,QueryData2,QueryResponse};
use ServiceStack\{ResponseStatus,ResponseError,EmptyResponse,IdResponse,ArrayList,KeyValuePair2,StringResponse,StringsResponse,Tuple2,Tuple3,ByteArray};
use ServiceStack\{JsonConverters,Returns,TypeContext};
class Attachment implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $Content=null,
/** @var string|null */
public ?string $Type=null,
/** @var string|null */
public ?string $Filename=null,
/** @var string|null */
public ?string $Disposition=null,
/** @var string|null */
public ?string $ContentId=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Content'])) $this->Content = $o['Content'];
if (isset($o['Type'])) $this->Type = $o['Type'];
if (isset($o['Filename'])) $this->Filename = $o['Filename'];
if (isset($o['Disposition'])) $this->Disposition = $o['Disposition'];
if (isset($o['ContentId'])) $this->ContentId = $o['ContentId'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Content)) $o['Content'] = $this->Content;
if (isset($this->Type)) $o['Type'] = $this->Type;
if (isset($this->Filename)) $o['Filename'] = $this->Filename;
if (isset($this->Disposition)) $o['Disposition'] = $this->Disposition;
if (isset($this->ContentId)) $o['ContentId'] = $this->ContentId;
return empty($o) ? new class(){} : $o;
}
}
class AttachmentStream implements JsonSerializable
{
public function __construct(
/** @var ByteArray|null */
public ?ByteArray $Stream=null,
/** @var string|null */
public ?string $Name=null,
/** @var string|null */
public ?string $Type=null,
/** @var string|null */
public ?string $Disposition=null,
/** @var string|null */
public ?string $Contentid=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Stream'])) $this->Stream = JsonConverters::from('ByteArray', $o['Stream']);
if (isset($o['Name'])) $this->Name = $o['Name'];
if (isset($o['Type'])) $this->Type = $o['Type'];
if (isset($o['Disposition'])) $this->Disposition = $o['Disposition'];
if (isset($o['Contentid'])) $this->Contentid = $o['Contentid'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Stream)) $o['Stream'] = JsonConverters::to('ByteArray', $this->Stream);
if (isset($this->Name)) $o['Name'] = $this->Name;
if (isset($this->Type)) $o['Type'] = $this->Type;
if (isset($this->Disposition)) $o['Disposition'] = $this->Disposition;
if (isset($this->Contentid)) $o['Contentid'] = $this->Contentid;
return empty($o) ? new class(){} : $o;
}
}
class SendMailRequest implements JsonSerializable
{
public function __construct(
/** @description Email address of sender. If it is not set the a default address will be used. */
// @ApiMember(Description="Email address of sender. If it is not set the a default address will be used.")
/** @var string|null */
public ?string $FromAddress=null,
/** @description List of recipient email addresses */
// @ApiMember(Description="List of recipient email addresses", IsRequired=true)
/** @var array<string>|null */
public ?array $Recipients=null,
/** @description Email subject */
// @ApiMember(Description="Email subject", IsRequired=true)
/** @var string */
public string $Subject='',
/** @description Plain text body. Either this or HtmlBody is required */
// @ApiMember(Description="Plain text body. Either this or HtmlBody is required")
/** @var string|null */
public ?string $Body=null,
/** @description Html body. Either this or Body is required */
// @ApiMember(Description="Html body. Either this or Body is required")
/** @var string|null */
public ?string $HtmlBody=null,
/** @description Email attachments */
// @ApiMember(Description="Email attachments")
/** @var string[]|null */
public ?array $Attachments=null,
/** @description Email attachments */
// @ApiMember(Description="Email attachments")
/** @var Attachment[]|null */
public ?array $AttachmentsObject=null,
/** @description Attachment streams */
// @ApiMember(Description="Attachment streams")
/** @var AttachmentStream[]|null */
public ?array $AttachmentStreams=null,
/** @description Template substitutions */
// @ApiMember(Description="Template substitutions")
/** @var array<string,string>|null */
public ?array $TemplateSubstitutions=null,
/** @description Template Id */
// @ApiMember(Description="Template Id")
/** @var string|null */
public ?string $TemplateId=null,
/** @description List of BCC email addresses */
// @ApiMember(Description="List of BCC email addresses")
/** @var array<string>|null */
public ?array $Bcc=null,
/** @description List of CC email addresses */
// @ApiMember(Description="List of CC email addresses")
/** @var array<string>|null */
public ?array $Cc=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['FromAddress'])) $this->FromAddress = $o['FromAddress'];
if (isset($o['Recipients'])) $this->Recipients = JsonConverters::fromArray('string', $o['Recipients']);
if (isset($o['Subject'])) $this->Subject = $o['Subject'];
if (isset($o['Body'])) $this->Body = $o['Body'];
if (isset($o['HtmlBody'])) $this->HtmlBody = $o['HtmlBody'];
if (isset($o['Attachments'])) $this->Attachments = JsonConverters::fromArray('string', $o['Attachments']);
if (isset($o['AttachmentsObject'])) $this->AttachmentsObject = JsonConverters::fromArray('Attachment', $o['AttachmentsObject']);
if (isset($o['AttachmentStreams'])) $this->AttachmentStreams = JsonConverters::fromArray('AttachmentStream', $o['AttachmentStreams']);
if (isset($o['TemplateSubstitutions'])) $this->TemplateSubstitutions = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','string']), $o['TemplateSubstitutions']);
if (isset($o['TemplateId'])) $this->TemplateId = $o['TemplateId'];
if (isset($o['Bcc'])) $this->Bcc = JsonConverters::fromArray('string', $o['Bcc']);
if (isset($o['Cc'])) $this->Cc = JsonConverters::fromArray('string', $o['Cc']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->FromAddress)) $o['FromAddress'] = $this->FromAddress;
if (isset($this->Recipients)) $o['Recipients'] = JsonConverters::toArray('string', $this->Recipients);
if (isset($this->Subject)) $o['Subject'] = $this->Subject;
if (isset($this->Body)) $o['Body'] = $this->Body;
if (isset($this->HtmlBody)) $o['HtmlBody'] = $this->HtmlBody;
if (isset($this->Attachments)) $o['Attachments'] = JsonConverters::toArray('string', $this->Attachments);
if (isset($this->AttachmentsObject)) $o['AttachmentsObject'] = JsonConverters::toArray('Attachment', $this->AttachmentsObject);
if (isset($this->AttachmentStreams)) $o['AttachmentStreams'] = JsonConverters::toArray('AttachmentStream', $this->AttachmentStreams);
if (isset($this->TemplateSubstitutions)) $o['TemplateSubstitutions'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','string']), $this->TemplateSubstitutions);
if (isset($this->TemplateId)) $o['TemplateId'] = $this->TemplateId;
if (isset($this->Bcc)) $o['Bcc'] = JsonConverters::toArray('string', $this->Bcc);
if (isset($this->Cc)) $o['Cc'] = JsonConverters::toArray('string', $this->Cc);
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /communication/sendmail HTTP/1.1
Host: duengageapi.uat.scadsoftware.com
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
FromAddress: String,
Subject: String,
Body: String,
HtmlBody: String,
Attachments:
[
String
],
AttachmentsObject:
[
{
Content: String,
Type: String,
Filename: String,
Disposition: String,
ContentId: String
}
],
AttachmentStreams:
[
{
Name: String,
Type: String,
Disposition: String,
Contentid: String
}
],
TemplateSubstitutions:
{
String: String
},
TemplateId: String
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
}