guides:programming:programmers_reference_manual:rti_cdomail

RTI_CDOMail function

This function will send emails from OpenInsight using authenticated logins and/or a Secure Sockets Layer (SSL).

RTI_CDOMail(mailservername,sendername, recipient, subject, body,cc, bcc, replyto, content, attachmentfilelist, Username, Password, useSSL, extraOptions)

The function has the following parameters:

ParameterDescription
mailservernameThe IP address of the mailserver.
sendernameThe email address of the sender of the email. This value may be either a simple string (the email address of the sender), or both a sender name and email address (separated by @FM).
recipientThe email address of the receiver of the email. Multiple email addresses can be delimited by either semicolons (;) or value marks (@vm). These values may be either simple strings (the email addresses of the recipients) or both recipient names (in field 1) and email addresses (in field 2).
subjectThe subject of the mail message.
bodyThe body of the mail message. This is text that is sent if the file to send is not able to be sent.
ccAdditional recipients of the mail message. Multiple email addresses can be delimited by either semicolons (;) or value marks (@vm). These values may be either simple strings (the email addresses of the recipients) or both recipient names (in field 1) and email addresses (in field 2).
bccAdditional recipients of the mail message. These recipients are unknown to all other recipients. Multiple email addresses can be delimited by either semicolons (;) or value marks (@vm). These values may be either simple strings (the email addresses of the recipients) or both recipient names (in field 1) and email addresses (in field 2).
replytoThe email address of the party that will receive any replies from the mail message. This value may be either a simple string (the email address to reply to), or both a reply to name and email address (separated by @FM).
contentThe content parameter specifies the html or alternate view of the email. Specify the alternate view (as either an html string or plain text) as the first field of this value, and the type of the alternate view (either “text/html”, or “text/plain” as appropriate) as the second field of this value. The alternate view may also be generated from an operating system (Windows) file; specify the file name (including file path) as the first field of the content parameter, and “file” as the second field of the content parameter.
attachmentfilelistAn @vm-delimited list of files to be attached to the email. The list should contain both paths and filenames.
usernameThe username of the mail account.
passwordThe password of the mail account.
useSSLA boolean flag. When TRUE$ SSL will be used when mailing.
extraOptionsA dynamic array of additional options for the email. Field 1 may contain either “priority” (to set the email priority) and/or “receipt” (to specify a read receipt), @VM delimited. Field 2 should then contain the priority value (“high”, “normal”, or “low”) and/or the email address the receipt should be sent to, in the associated value position.

OpenInsight will return the error message received from CDO. These error message generally relate to configuration issues with CDO. The errors are version specific, therefore it is recommended that Microsoft's documentation be referenced.

In OpenInsight 10+, this function is now a thin wrapper around RTI_EMAIL_CLIENT. For details on options, please see RTI_EMAIL_CLIENT.

Prior to OpenInsight 10, this function was built using the .Net SMTP client library (System.Net.Mail.SmtpClient assembly).

If the body parameter is not specified, and a value is specified for the content parameter, then the email will be sent as an “html email” (the value of the content field 1 will be used as the body of the email).


mailservername = 'my.mailserver.com'

mailserverPort='999';* use the proper port

mailServer = mailServerName:':':mailserverPort

username = 'my_username'

password = 'my_password'

useSSl = 1

body = 'This is a test of CDO Mail''

retval = rti_cdoMail( mailserver, sendername, recipient, subject, body, cc, bcc, replyto, content, attachmentfilelist, username, password, useSSl )
function example_sendMail(recipient, subject, messageBody, attachmentfilelist, cc, bcc, replyto )
/*
**  OI10.2 example
**  Uses the IDE settings to obtain the email credentials
**  Wrapper around RTI_CDOMAL to get the mail setting from the config
*/
     $insert rti_IDE_Cfg_Equates
     $insert logical
     $insert msg_equates
     $insert rti_text_Equates

     Declare Function rti_cdomail, exec_method

     If Assigned(recipient) Else recipient = null$
     If Assigned(subject) Else subject = null$
     If Assigned(messageBody) Else messageBody = null$
     If Assigned(attachmentfilelist) Else attachmentfilelist = null$
     If Assigned(cc) Else cc = null$
     If Assigned(bcc) Else bcc = null$
     If Assigned(replyto) Else replyto = null$

     body    = null$
     If IndexC( messageBody, "<HTML",1) Then
          body    = null$
          content = messageBody
     End Else
          body    = messageBody
          content = content
     end


     * Get the mail server information from the OI10 IDE settings
     * NOTE: If you are using a mail service such as gmail with 2 factor authentication enabled then you will need to get an 'application password' for your account. 
     serverName = rti_ide_cfg("GETVALUE", IDE_CFG_POS_EDIT_EMAIL_MAILSERVER$)
     senderName = rti_ide_cfg("GETVALUE", IDE_CFG_POS_EDIT_EMAIL_SENDERNAME$)
     userName = rti_ide_cfg("GETVALUE", IDE_CFG_POS_EDIT_EMAIL_USERNAME$)
     userPwd = rti_ide_cfg("GETVALUE", IDE_CFG_POS_EDIT_EMAIL_PASSWORD$)
     useSSL = rti_ide_cfg("GETVALUE", IDE_CFG_POS_EDIT_EMAIL_USESSL$)

     //otherOptions = rti_ide_cfg("GETVALUE",IDE_CFG_POS_EDIT_EMAIL_OPTIONS$ )
     * these days you always need tls 
     otherOptions = 'tlsprotocol':@vm:'tls12'


     * assume options name value pairs with = deliminting name, value and comma delimiting pairs,
     * the options wants an array of vm delimited names, vm delimited values
   

     ret = rti_CDOMail(servername, sendername, recipient, subject, body,cc, bcc, replyto, content, attachmentfilelist, Username, userPwd, useSSL, otherOptions)

     if ret != null$ then
        convert @fm to '|' in ret
        call msg(@window, ret)
     end

return ret
  • guides/programming/programmers_reference_manual/rti_cdomail.txt
  • Last modified: 2024/10/25 18:45
  • by bshumsky