---
title: "Email"
canonical: "https://docs.cuesystem.com/space/CVCHELP/510787925/Email"
format: markdown
---
> Macro (toc)

---

# SendEmail  

The command sends an email by its parameters. The command returns True on success or False if an error occurs. 

The function GetLastError returns the error number that occurred while executing the command. The errors that can happen: <u>[121](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#121)</u>, <u>[123](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#123)</u>, <u>[124](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#124)</u>, <u>[125](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#125)</u>, <u>[126](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#126)</u>, <u>[127](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#127)</u>, <u>[128](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#128)</u>, <u>[129](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#129)</u>, <u>[130](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#130)</u>, <u>[131](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#131)</u>, <u>[132](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#132)</u>. 

**Important note**: It is necessary to set the web admin <u>SMTP</u> and <u>email</u> configurations. If they are set wrong, the email will not be sent. 

#### Syntax 

```visualbasic
Function SendEmail( 
  recipientaddress As Text 
  subject As Text, 
  body As Text, 
  Optional attachment As Text = "") 
As Boolean
```

#### Parameters 

recipientaddress 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> It is an expression that identifies one or more recipients. If there are more recipients, they must be separated by characters (,) comma or (;) semicolon. Rules of the recipient name: The recipient can be specified by email address or by a combination of email address and a real name. The email address must be specified always, the name is optional. If the name is specified, it must be specified as the first. The email must follow enclosed in characters < less-than and > greater-than. If the name is not specified, the email address can be (but needn’t) enclosed in characters < and >. Spaces between the last valid character of the name and character < are unimportant. Spaces before the name are unimportant. Spaces behind the email address are unimportant. 

***Example**** *

[john.newton@yahoo.com](mailto:john.newton@yahoo.com)   
< [john.newton@yahoo.com](mailto:john.newton@yahoo.com) >   
John Newton < [john.newton@yahoo.com](mailto:john.newton@yahoo.com) >

subject 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> It is the subject of the email. 

body 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> It is the text of the body of the email. 

attachment 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Optional. It is a list of attachments. The default value is "" (empty string). If there are more attachments, they must be separated by characters (,) comma or (;) semicolon. The file names must match the [rules of names](/wiki/spaces/CVCHELP/pages/512983041/Files+folders#Names-of-files-and-folders). The names are case-sensitive on the CUEunits. 

**Important note:** All attached files must exist. If any of them does not exist, the email will not be sent. 

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> This function returns True on success or False if an error occurs. The function GetLastError returns the error number. 

#### Example 

```visualbasic
SendEmail("John Newton <john.newton@yahoo.com>", "New version", "Dear John, I send you a new version of System Director. Best regards. Yours Peter")
```

# SendPresetEmail 

The recipient is specified by the number of the mailbox defined in the <u>email</u> configuration. The command returns True on success or False if an error occurs. 

The function GetLastError returns the error number that occurred while executing the command. The errors that can happen: <u>[121](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#121)</u>, <u>[123](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#123)</u>, <u>[124](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#124)</u>, <u>[125](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#125)</u>, <u>[126](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#126)</u>, <u>[127](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#127)</u>, <u>[128](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#128)</u>, <u>[129](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#129)</u>, <u>[130](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#130)</u>, <u>[131](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#131)</u>, <u>[132](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#132)</u>. 

**Important note**: It is necessary to set the web admin <u>SMTP</u> and <u>email</u> configurations. If they are set wrong, the email will not be sent. 

#### Syntax 

```visualbasic
Function SendPresetEmail( 
  recipientnumber As Long, 
  subject As Text, 
  body As Text, 
  Optional attachment As Text = "") 
As Boolean
```

#### Parameters 

recipientnumber 

<u>[Long](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is the number (1–4) of the mailbox. The mailbox must be specified in the <u>email</u> configuration. 

subject 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> It is the subject of the email. 

body 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> It is the text of the body of the email. 

attachment 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Optional. It is a list of attachments. The default value is "" (empty string). If there are more attachments, they must be separated by characters (,) comma or (;) semicolon. The file names must match the [rules of names](/wiki/spaces/CVCHELP/pages/512983041/Files+folders#Names-of-files-and-folders). The names are case-sensitive in the CUEunit. 

**Important note:** All attached files must exist. If any of them does not exist, the email will not be sent. 

#### Example 

/filestorage/file.txt   
/filestorage/first_file.txt, /filestorage/second_file.txt

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> This function returns True on success or False if an error occurs. The function GetLastError returns the error number. 

#### Example 

```visualbasic
SendPresetEmail(1, "New version", "Dear John, I send you a new version of System Director. Best regards. Yours Peter")
```

#### AdminWeb - SMTP configuration 

Two types of authentication are supported: PLAIN and LOGIN. The LOGIN type is the mostly used type. When the authentication Type is selected, the Username and Password must be entered. 

![image](media://ab857f7e-3aca-41b8-bd87-7aae1eb2e56b)

#### AdminWeb - Email configuration 

![image](media://de9d6585-0033-4fa2-bf68-0b54140595c9)