COM Integration/How to send email

Requires Analytica Enterprise or better

Download: How to send email.ana

The example model provides a UDF to send and email and demonstrates how to use it.

Configuring Email Settings in Analytica

The first thing you need is an Email_configuration table with the necessary information for the SMTP server. This is defined as Table(Self) with the values shown below.

Email configuration.png

This includes details about the email server you'll be using, your email account, and how to securely connect. Below are the fields you'll need to fill out and guidance on where to find this information.

1. sendusing

  • What it is: This field specifies the method of sending the email.
  • Value: Typically set to 2 to indicate using an SMTP server.

2. smtpserver

  • What it is: The address of your email provider's SMTP server.
  • Where to find it:
    • For Gmail: `smtp.gmail.com`
    • For Outlook: `smtp-mail.outlook.com`
    • For Yahoo: `smtp.mail.yahoo.com`
    • Check your email provider's documentation for other services.

3. smtpauthenticate

  • What it is: Indicates whether authentication is required.
  • Value: Typically set to 1, meaning authentication is required.

4. sendusername

  • What it is: Your email address, used as the username for authentication.
  • Where to find it: This is the full email address you use to log into your email account. For example, `yourname@example.com`.

5. sendpassword

  • What it is: The password for your email account.
  • Important Note: For security reasons, if you are using Gmail or another service that uses two-factor authentication, you may need to generate an "App Password" specifically for this purpose rather than using your regular email password.
  • Where to find it: In your email account settings, look for security options, where you can generate an app-specific password.

6. smtpserverport

  • What it is: The port number used by the SMTP server for secure email sending.
  • Where to find it:
    • For Gmail and most other providers using SSL: 465
    • For providers using TLS (which is another form of security): 587

7. smtpusessl

  • What it is: Indicates whether SSL (Secure Sockets Layer) is used for secure communication.
  • Value: Typically set to 1 to use SSL. For TLS, you may use 2.

8. smtpconnectiontimeout

  • What it is: The time in seconds before the connection times out.
  • Value: A typical value is 60 seconds, but you can adjust based on your network reliability.

Example Configuration for Gmail

  • sendusing: 2
  • smtpserver: `smtp.gmail.com`
  • smtpauthenticate: 1
  • sendusername: `yourname@gmail.com`
  • sendpassword: `yourAppPassword`
  • smtpserverport: 465
  • smtpusessl: 1
  • smtpconnectiontimeout: 60

Steps to Find SMTP Details for Other Email Providers

  1. Search Online: Use keywords like "SMTP settings for [your email provider]" to find the correct server and port information.
  2. Check Email Account Settings: Many email services have detailed help sections where you can find this information.
  3. Contact IT Support: If you're using a corporate email service, your IT department can provide the necessary details.

Send email function

Use this function to send an email, for example, from a button.

Function Send_email( toAddresses, Subject, body )
Description: Sends an email to the given addresses.  Addresses may be separated by commas.
Definition:
    Local msg := COMCreateObject("CDO.Message");
    msg->Subject := Subject;
    msg->From := "DoNotReply@AnalyticaCloud.com";
    msg->TextBody := body;
    msg->To := toAddresses;
    Local cfg := msg->Configuration;
    Local prefix := "http://schemas.microsoft.com/cdo/configuration/";
    cfg->Fields( prefix & IndexValue(Email_configuration)) := Email_configuration;
    cfg->Fields->Update();
    msg->Send()

Example usage

Send_email( 'john.doe@gmail.com', 'Here is a test', 'John -- I hope you receive this email' )
Comments


You are not allowed to post comments.