Hi,
I am fairly new to scripting and would really appreciate all the help I can get to tackle this challenge.
I have a scheduler set up to export a range of data log and alarm server files daily to 'project files folder' in the panel. The exported files do not overwrite.
After the scheduler exports it to the project files folder, I need an email script to immediately send these exported files to one or more email addresses.
I have looked at the Script_Email sample, but I am not sure how to go about modifying it to perform the above.
Thanks
Scheduled Emails with Data Loggers Attachments
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: Scheduled Emails with Data Loggers Attachments
Unfortunately we do not have the resources to customize scripts for specific customers. The Script_Email has all the functions that you would need to attach a document to an email. In the "Alarm Distributor"->"Configure Distribution Devices" you configure the email server that relays the message.
Best Regards,
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Re: Scheduled Emails with Data Loggers Attachments
No worries Mark.
I'll need some help with a few basics and then hopefully I can work my way through this.
To add an attachment and specify its path, what syntax would I use?
I'll need some help with a few basics and then hopefully I can work my way through this.
To add an attachment and specify its path, what syntax would I use?
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: Scheduled Emails with Data Loggers Attachments
Hi Sarah,
The example has how to add a file to an email. It is programmed on screen1. In the lower left hand corner of the screen is text that says "Script". Click on that it it will show you the code to create an email.
There are many posts on this forum on file paths and where files are located.
The example has how to add a file to an email. It is programmed on screen1. In the lower left hand corner of the screen is text that says "Script". Click on that it it will show you the code to create an email.
There are many posts on this forum on file paths and where files are located.
Best Regards,
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Re: Scheduled Emails with Data Loggers Attachments
Sorry Mark, it appears my question was too vague and was therefore misinterpreted.
But I have managed to get the email to add a specific attachment, so that's one step forward. In screen 1, I used the following (modifications shown in bold):
void SendButton_Click(System.Object sender, System.EventArgs e)
{
string filePath = "C://.../datalogger.xlsx";
string messageResult = Globals.MailScriptModule.SendEmail(RecieverTextBox.Text, SubjectTextBox.Text, BodyTextBox.Text, filePath);
MessageBox.Show(messageResult);
}
In the 'mail script module', I deleted the parts where it created an attachment and edited the line 'attachments.Add(attachment);'
However, the attachment gets renamed so that it includes the file location in it. I'm not sure why it's doing this. Any ideas?
But I have managed to get the email to add a specific attachment, so that's one step forward. In screen 1, I used the following (modifications shown in bold):
void SendButton_Click(System.Object sender, System.EventArgs e)
{
string filePath = "C://.../datalogger.xlsx";
string messageResult = Globals.MailScriptModule.SendEmail(RecieverTextBox.Text, SubjectTextBox.Text, BodyTextBox.Text, filePath);
MessageBox.Show(messageResult);
}
In the 'mail script module', I deleted the parts where it created an attachment and edited the line 'attachments.Add(attachment);'
However, the attachment gets renamed so that it includes the file location in it. I'm not sure why it's doing this. Any ideas?
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: Scheduled Emails with Data Loggers Attachments
I think you just need to comment out one line of code and you can leave the rest the same. I am not sure why your file is being renamed.
I would leave the MailScriptModule the same and use the below code in the screen:
I would leave the MailScriptModule the same and use the below code in the screen:
Code: Select all
namespace Neo.ApplicationFramework.Generated
{
using System.Windows.Forms;
using System;
using System.Drawing;
using Neo.ApplicationFramework.Tools;
using Neo.ApplicationFramework.Common.Graphics.Logic;
using Neo.ApplicationFramework.Controls;
using Neo.ApplicationFramework.Interfaces;
using System.IO;
public partial class Screen1
{
void SendButton_Click(System.Object sender, System.EventArgs e)
{
// Create a dummy attachement to send with the mail.
//string attachementPath = Globals.MailScriptModule.CreateAttachement();
string attachementPath = "C:\\...";
// Call the script module with the recievers mail address, subject and message body.
// The message result tells if things went good or bad.
string messageResult = Globals.MailScriptModule.SendEmail(RecieverTextBox.Text, SubjectTextBox.Text, BodyTextBox.Text, attachementPath);
// Display the message result.
MessageBox.Show(messageResult);
}
}
}
Best Regards,
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
-
- Posts: 6
- Joined: Sat Sep 28, 2013 9:37 am
Re: Scheduled Emails with Data Loggers Attachments
Hi all
I am having problems with getting the exact locations of where the files are stored.
I can get emailing to work but now need to know the exact path of where the datalogger files are stored can someone help?
I am having problems with getting the exact locations of where the files are stored.
I can get emailing to work but now need to know the exact path of where the datalogger files are stored can someone help?
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: Scheduled Emails with Data Loggers Attachments
On a WinCE unit the"\Flashdrive" is the unit's hard disk and a USB comes up as a "\Harddisk". You should search this forum for the terms and you will find lots of information on where files are located. Our PC units use the standard "c:" paths.
Best Regards,
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
-
- Posts: 6
- Joined: Sat Sep 28, 2013 9:37 am
Re: Scheduled Emails with Data Loggers Attachments
mark.monroe wrote:On a WinCE unit the"\Flashdrive" is the unit's hard disk and a USB comes up as a "\Harddisk". You should search this forum for the terms and you will find lots of information on where files are located. Our PC units use the standard "c:" paths.
Please could you help one last time I have emailing working well now but want to schedule it to send date on a change of shift. I see no reference to running scripts from the Scheduler, it this possible to do this.
-
- Posts: 6
- Joined: Sat Sep 28, 2013 9:37 am
Re: Scheduled Emails with Data Loggers Attachments
lawrenceelectrical wrote:mark.monroe wrote:On a WinCE unit the"\Flashdrive" is the unit's hard disk and a USB comes up as a "\Harddisk". You should search this forum for the terms and you will find lots of information on where files are located. Our PC units use the standard "c:" paths.
Please could you help one last time I have emailing working well now but want to schedule it to send date on a change of shift. I see no reference to running scripts from the Scheduler, it this possible to do this.
Thanks Sorted that!!