Showing posts with label Niagara-ax email. Show all posts
Showing posts with label Niagara-ax email. Show all posts

Sunday, September 27, 2015

Outgoing email in Tridium Niagara Ax using a Free GMail account

The email OutgoingAccount component is required for sending emails from a station. This component is located in the email palette .













Drag the EmailService from the palette and drop it on the Services group in the tree as shown below.

 
Now click on the plus sign to expand the EmailServices and then double click on the OutgoingAccount to bring up the property sheet.

 OutgoingAccount property sheet view 

The OutgoingAccount has the following properties that need changing from there default settings:

Hostname

This is the name of the mail server. In this example the host name is smtp.gmail.com

Port

This is the port number associated with the email account. Typically email outgoing account port numbers are port "25", however, if you leave the setting at its default value of "-1" the OutgoingAccount will search for and use a valid port. However Gmail uses  a different port , so in the port textbox type 465.

Account

This is the name of the distinct account that is authorized for access to the "Hostname" mail server. For example, if you are using an email account named "jon@gmail.com", your account name is your full GMail address.

Password

This is the login credential for the GMail address specified in the Account field.


Enabled

This field allows you to activate or deactivate the account by choosing true or false, respectively.

Debug

This Boolean property turns Debug mode on true or off, as desired. When Debug is turned on, you can see detailed debug information in a station's standard output view (WorkbenchAX Platform > Application Director view) when the Station tries to send or receive email. This can be used to troubleshoot the accounts and faults.

Use Ssl

The Ssl (Secure Socket Layer) option is available on the OutgoingAccount starting in NiagaraAX-3.5. The option list allows you to disable Ssl (false) or enable it (true). Enable Ssl for communication with a host email server that requires it.

 Niagara-AX, set up your "Outgoing Account" as pictured below:

Be sure to verify your DNS servers are correctly assigned .

To allow Gmail SMTP to work with the Niagara-AX email service, Gmail 2-step verification must be disabled. Please be warned that this will leave your Gmail account more vulnerable to outside intrusion. I recommend creating and utilizing a new Gmail account that will be solely used for SMTP relays.



On the top right, locate the "Account" icon.
 Click the "My Account" button.

From the menu, click "Sign-in & Security".




From the menu on the left select Signing in to Google



Locate "2-Step Verification".
  Click the "Settings" hyperlink. To disable 2-Step Varication.

Saturday, February 9, 2013

Configure Niagara Ax to send Email


Configure Niagara Ax to send Email


The below steps explains how to configure the email service in Naigara Ax station, using its workbench. And below you will find the code to use the baja Email api to be able to send email in Niagara.
Navigate to BEmailService service under Station
Double click on the EmailService, you will find the Email Account Manager.
Click New Button
Provide the Outgoing Account information including the smtp server and port. And click ok.

email1


Now right click on the added account manager and choose Actions->Send
Now provide your email id information in from and to address fields. And click Ok.
In your station spy if you have enabled trace for module ‘email’. Then you can see the message below in station console.

 Code to Send Email

public void doSendEmail(){
 BEmailService bemailservice =
 (BEmailService)Sys.getService(BEmailService.TYPE);
 bemailservice.lease(2);
 BOutgoingAccount outGoingAccount =
 (BOutgoingAccount)bemailservice.getDefaultOutgoingAccount();
 if(outGoingAccount == null) {
  System.out.println("Email Service not configured")
  return;
 }
 BEmail mail = new BEmail();
 mail.setFrom(BEmailAddress.make("My Name", "myname@domain.com"));
 //Add to address
 List<BEmailAddress> toEmailList = new ArrayList<BEmailAddress>();
 toEmailList.add(BEmailAddress.make("Your Name","yourname@domain.com"));
 BEmailAddressList listEmail = BEmailAddressList.make(
    toEmailList.toArray(new BEmailAddress[toEmailList.size()]));
 mail.setTo(listEmail);
 mail.setDate(BAbsTime.now());
 mail.setSubject("Test Subject");
 // Add attachment
 BEmailPartList part = new BEmailPartList();
 //part.addAttachment(BOrd.make("ord to attachement file"));
 mail.setAttachments(part);
 //Add body
 StringBuffer body = new StringBuffer();
 body.append("This is a test mail ");
 mail.setBody(new BTextPart(body.toString()));
//send mail
 outGoingAccount.send(mail);
}

Detailed description to configure Email can be found here.