> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Message

> Represents a Service ticket message.

Represents a Service ticket message.

## Constructors

### Message()

```crmscript theme={null}
Message
```

Initializes a new instance of the Message class.

## Methods

## addHeader(String,String)

Adds a header to the message. The headers will be shown at the view request page, listed at the message.

```crmscript theme={null}
Void addHeader(String type, String value)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

<Note>
  This method will only add a header if the message has been loaded or saved first. You do not need to call save() after this method.
</Note>

## convertInlineImages()

Convert any inline images in the message from (cid: to normal http).

```crmscript theme={null}
Void convertInlineImages()
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

## getAttachments()

Returns an array of all the attachment IDs on the message.

```crmscript theme={null}
Integer[] getAttachments()
```

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer)\[] - Array of attachment IDs.

## getValue(String)

Returns the value a column.

```crmscript theme={null}
String getValue(String colName)
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - A string value of the column.

<Note>
  Possible columns:

  * ticketId: Integer, The ticket this message is a child of.
  * customerId: If the message was created by email or from the customer center, this field will point to that customer. -1 if the message was created by an user
  * createdAt: Datetime when the message was created.
  * createdBy: Integer, The ID of the user who posted the message. The value 1 (system user) for externally posted messages.
  * type: String, The type of the message (plaintext/html).
  * searchTitle: A copy of the title of the ticket, for search optimisation and simpler reporting.
  * author: String, A string representing the author of the message. Could be a user's name, or a persons email address.
  * slevel: String, The securitylevel of the message (1 is internal, 2 is external).
  * messageId: String, The X-Message-Id header value from the email. Used for threading, i.e. connecting messages to existing tickets.
  * timeSpent: Integer, The time spent (minutes) for this message.
  * emailHeader: The email header is saved in this field as raw text
  * debugInfo: The debug info for the message.
  * important: True if this message is important.
  * mailSorter: The name of the mail sorter used when the email was imported. Note: We must use name instead of id since the id's change every time one changes the mail sorter.
  * inlineImages: True if message contains inline images.
  * htmlBodyInlineConverted: True if the html\_body has converted inline image links.
  * inlineConverted: True if the html\_body has converted inline image links.
  * body: String, The textbody for the message.
  * bodyHtml: String, The HTML body for the message (if any).
  * badge: String, defines the initial source of message. See \<xref href="CRMScript.NetServer.BadgeType" data-throw-if-not-resolved="false">\</xref>.
  * x\_... : Extra fields
</Note>

## load(Integer)

Loads the message with the given ID.

```crmscript theme={null}
load(Integer id)
```

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool) - True if successful; otherwise, false.

## save()

Saves a message and returns the database ID.

```crmscript theme={null}
Integer save()
```

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - The database Id.

<Note>
  You can optionally add logging.
</Note>

## save(String)

Saves a message and returns the database ID.

```crmscript theme={null}
Integer save(String log)
```

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - The database Id.

<Note>
  Use save() if you don't want to add logging.
</Note>

## save(String.Bool)

Saves a message and returns the database ID.

```crmscript theme={null}
Integer save(String log, Bool noNewInfo)
```

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - The database Id.

<Note>
  Use save() if you don't want to add logging.
</Note>

## saveInvolved(String)

Saves the email address of a single recipient of a message.

```crmscript theme={null}
Void saveInvolved(String emailAddress)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

<Note>
  Use save(Vector) to save a collection of addresses.
</Note>

## saveInvolved(Vector)

Saves the email address of a single recipient of a message

```crmscript theme={null}
Void saveInvolved(Vector emailAddresses)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

<Note>
  Use save(String) to save a single email address.
</Note>

## send(Vector,Vector,Vector)

Sends an email version of the message to the main contacts on the parent ticket.

```crmscript theme={null}
Bool send(Vector to, Vector cc, Vector bcc)
```

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool) - True if everything is OK; otherwise, false.

<Note>
  Use one of the other variants if you want to merge with reply template or set subject and a heading for the body part.
</Note>

## send(Vector,Vector,Vector,Integer)

Sends an email version of the message to the main contacts on the parent ticket. Merges with reply template in the settings of the submitted category ID.

```crmscript theme={null}
Bool send(Vector to, Vector cc, Vector bcc, Integer categoryId)
```

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool) - True if everything is OK; otherwise, false.

## send(Vector,Vector,Vector,String)

Sends an email version of the message to the main contacts on the parent ticket using the given subject

```crmscript theme={null}
Bool send(Vector to, Vector cc, Vector bcc, String subject)
```

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool) - True if everything is OK; otherwise, false.

<Note>
  You can optionally provide a heading for the body part.
</Note>

## send(Vector,Vector,Vector,String,String)

Sends an email version of the message to the main contacts on the parent ticket using the given subject, and a given heading for the body part.

```crmscript theme={null}
Bool send(Vector to, Vector cc, Vector bcc, String subject, String bodyHeading)
```

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool) - True if everything is OK; otherwise, false.

<Note>
  The body heading may be empty for no heading, or null for default heading (same as not using this parameter).
</Note>

## sendFacebook()

Posts message to Facebook

```crmscript theme={null}
Void sendFacebook()
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

## sendSms(Vector)

Sends an sms-version of the message to the numbers in the vector.

```crmscript theme={null}
Bool sendSms(Vector to)
```

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool) - True if successful; otherwise, false.

## setAttachments(Vector)

Connects the attachments to the message.

```crmscript theme={null}
Void setAttachments(Vector ids)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

<Note>
  You must do a message.save before message.setAttachments.
</Note>

## setValue(String,String)

Sets the value of column colName to the given value

```crmscript theme={null}
Void setValue(String colName, String value)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

<Note>
  Possible columns:

  * ticketId: Integer, The ticket this message is a child of.
  * customerId: If the message was created by email or from the customer center, this field will point to that customer. -1 if the message was created by an user
  * createdAt: Datetime when the message was created.
  * createdBy: Integer, The ID of the user who posted the message. The value 1 (system user) for externally posted messages.
  * type: String, The type of the message (plaintext/html).
  * author: String, A string representing the author of the message. Could be a user's name, or a persons email address.
  * slevel: String, The securitylevel of the message (1 is internal, 2 is external).
  * messageId: String, The X-Message-Id header value from the email. Used for threading, i.e. connecting messages to existing tickets.
  * timeSpent: Integer, The time spent (minutes) for this message.
  * emailHeader: The email header is saved in this field as raw text
  * debugInfo: The debug info for the message.
  * important: True if this message is important.
  * mailSorter: The name of the mail sorter used when the email was imported. Note: We must use name instead of id since the id's change every time one changes the mail sorter.
  * inlineImages: True if message contains inline images.
  * body: String, The textbody for the message.
  * bodyHtml: String, The HTML body for the message (if any).
  * badge: String, defines the initial source of message. See \<xref href="CRMScript.NetServer.BadgeType" data-throw-if-not-resolved="false">\</xref>.
  * x\_... : Extra fields
</Note>

## toParser(Parser)

This function loads many fields of the message to the input parser.

```crmscript theme={null}
Void toParser(Parser parser)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

<Note>
  The fields will be loaded as message.value

  * message.id, The ID of the message
  * message.slevelInteger, The security level of the message. See \<xref href="CRMScript.NetServer.TicketSecurityLevel" data-throw-if-not-resolved="false">\</xref>.
  * message.slevel, The security level of the message as a String, according to the active user's language.
  * message.createdAt, The datetime when the message is created in format 12. jan 1998, kl. 11:23.
  * message.createdAtRaw, The datetime when the message is created in format 1998-01-12 11:23:15
  * message.author, The author of the message
  * message.bodyHtml, The HTML body of the message
  * message.messageCategory, The message category. See \<xref href="CRMScript.NetServer.TicketMessageCategory" data-throw-if-not-resolved="false">\</xref>.
  * message.body, The body of the message, if this is a plaintext message, this text will be returned with activated links
  * message.bodyPlain, The body of the message exactly as saved in database.
  * message.header, The message header
  * message.mailSorter, If this message is a recieved mail, the this is the name of the mail filter that took it.
  * message.x\_myextrafield, The value of the extrafield
</Note>


## Related topics

- [Messages](/en/developer-portal/create-app/message-center.md)
- [System Messages](/en/developer-portal/best-practices/system-messages.md)
- [Edit message](/en/request/learn/edit-message.md)
- [Chatbot messages](/en/automation/chatbot/messages.md)
- [Split message](/en/request/learn/split-message.md)
