Email Examples

Emails may be generated for sending on mobile devices using BrightForms. This is typically performed by specifying the fields such as the 'To' address via methods, then calling the Send() method of the email object. Typically, this call will open the device's native email client and configuration, populated with the fields configured in BrightForms, and is sent once the user sends it from this client.

Outside of this, emails may also be generated on BrightServer using a similar Email object and Scripts. For examples of server side email generation, please refer to the Email Examples topic in the Script Methods Reference chapter of this document.

Send an email

Email.Reset();

Email.AddTo("test@example.com");

local.vResult = Email.Send("Subject", "Body");

Form.MessageBox("Email Sending", local.vResult, 0);

Note:

Send an email with CC and BCC addresses

Email.Reset();

Email.AddTo("test@example.com");

Email.AddCc("test_cc@example.com");

Email.AddBcc("test_bcc@example.com");

local.vResult = Email.Send("Subject", "Body");

Form.MessageBox("Email Sending", local.vResult, 0);

Note:

Sending an email with scribble data attachment

//First, save the scribble as a JPG

local.vFile = System.GetProjectPath() & "/" & "filename.jpg";

scribbleControl.SaveJPEGFile(local.vFile);

 

//Proceed to send the email

Email.Reset();

Email.AddTo("test@example.com");

Email.AddAttachment(local.vFile);

local.vResult = Email.Send("Subject", "Body");

Form.MessageBox("Email Sending", local.vResult, 0);

Note:

Sending an email via SMTP (Web, Android only)

Email.Reset();

 

Email.SetFromAddress("user@example.com");

Email.SetFromName("Example Username");

Email.SetHost(mail.example.com);

Email.SetPort(25);

 

Email.AddTo("test@example.com");

local.vResult = Email.Send("Subject", "Body");

Form.MessageBox("Email Sending", local.vResult, 0);

Note:

Sending an email via IMAP with Authentication (Web, Android only)

Email.Reset();

 

Email.SetProtocol("imap");

Email.SetEnableSSL(true);

Email.SetFromAddress("example.from.address@gmail.com");

Email.SetFromName("Example Username");

Email.SetHost(imap.gmail.com);

Email.SetPort(993);

Email.SetUserCredentials("example.from.address@gmail.com", "example.pass");

 

Email.AddTo("test@example.com");

local.vResult = Email.Send("Gmail IMAP (SSL)", "Body");

Form.MessageBox("Email Sending", local.vResult, 0);

Note: