The AmtEmail object is returned by the CreateAmtEmail function provided through the ComScript connection interface. This object exposes the functionality of the AmtEmail utility in programs written in any COM-supporting development environment.
The following functionality is provided:
| Name | Type | Access | Description |
|---|---|---|---|
| BCC | String | Read/Write | Sets the BCC (blind carbon copy) for the message to be sent. Separate multiple addresses with commas. |
| CC | String | Read/Write | Sets the CC (carbon copy) for the message to be sent. Separate multiple addresses with commas. |
| Content | String | Read/Write | Sets the CONTENT of the message to be sent. |
| From | String | Read/Write | Sets the FROM of the message. |
| LastErrorMessage | String | Read | Returns the last error message. |
| ReceivedDate | String | Read/Write | Returns the date the message was received. |
| ReplyTo | String | Read/Write | Sets the optional REPLY-TO field. Separate multiple addresses with commas. |
| Subject | String | Read/Write | Sets the subject description. |
| To | String | Read/Write | Sets the TO (recipient) field. Separate multiple addresses with commas. |
| Function Name | Return type | Parameters | Description | |
|---|---|---|---|---|
| Name | Type | |||
| AddAttachment | Boolean | FileName | String | Sets the attachment or attachments for the e-mail to be sent. A path may be included. Separate multiple file names with a semicolon (;). |
| ClearMessage | Boolean | None | Clears all settings for the e-mail to be sent. | |
| Connect | Void | SmtpServerAddress | String | Tests the SMTP connection by sending a HELO command. |
| Port | Integer | |||
| Name | String | |||
| Password | String | |||
| DeleteMessage | Boolean | None | Marks the current received e-mail message for deletion. For example, if you fetch four messages from your mailbox and only call the DeleteMessage function after the fourth message, only the fourth message is deleted. The other three messages remain on the POP3 server. DeleteMessage is always the last function called in an e-mail receiving routine. | |
| GetAttachments | String | Directory | String | Returns a list with the filenames of the attachments and puts the physical files in the specified directory. |
| GetNrOfMessages | Integer | None | Returns the number of messages on the mail server. info Note: If messages are marked for deletion through the DeleteMessage function, the marks are removed after the GetNrOfMessages function is executed. This means the messages are not deleted physically. This function also resets the internal message count. | |
| Pop3LogOff | Boolean | None | Logs off and disconnects from the POP3 server. | |
| Pop3LogOn | Boolean | Server | String | Logs on to the POP3 server that must be used for fetching the e-mail. The optional parameter to use SSL/TLS defaults to False. |
| Port | Integer | |||
| User | String | |||
| Password | String | |||
| [UseSSL] | Boolean | |||
| ReadMessage | Boolean | MsgNo | Integer | Checks the POP3 server for new e-mail messages for the e-mail account and retrieves all data (for example, TO, CC, SUBJECT) for the current message or, if specified, the message indicated by the MsgNo value. If this function is called more than once, it retrieves the next message each time. If there are no messages, the internal message counter is reset, and a new incoming message can be retrieved afterward. |
| SendLastReveivedMessage | Boolean | None | Sends the last received message to a new destination. This function simply forwards the current message. | |
| SendMessage | Boolean | None | Sends the previously built e-mail to the SMTP server. Before executing this instruction, make all required preparations for the e-mail. If the e-mail address is not in the correct format, the function returns false. | |
| SetFormat | Boolean | Format | String | Sets the format of the message to be sent. The available options are HTML for HTML format and TEXT for plain text format. |
| SmtpLogOff | Boolean | None | Logs off and disconnects from the SMTP server. | |
| SmtpLogOn | Boolean | Server | String | Logs on and connects to the SMTP server. Optional credentials can be used. The optional parameter to use SSL/TLS defaults to False. When the logon fails, the function will return false. |
| Port | Integer | |||
| [Name] | String | |||
| [Password] | String | |||
| [EnableSSL] | Boolean | |||
# See ComScript Connection Interface
# ...
$ComScr.Connect()
# Create an AmtEmail object
$AmtEmail = $ComScr.CreateAmtEmail()
# Logon to the SMTP server
$AmtEmail.SmtpLogOn("smtp.example.org", 25)
# Use the properties and functions of the AmtEmail object
$AmtEmail.From = "john@example.org"
$AmtEmail.To = "jane@example.com"
$AmtEmail.Cc = "bob@example.net"
$AmtEmail.BCC = "bill@example.org"
$AmtEmail.Subject = "Testing AmtEmail from a Powershell script"
$AmtEmail.Content = "Test succeeded!!"
$AmtEmail.AddAttachment("attachment.pdf")
# Send the email
$AmtEmail.SendMessage()
# Logoff from the SMTP server
$AmtEmail.SmtpLogOff()
# Finally release the variables and clean up the session.
$ComScr.Dispose()