Hi again.... I am looking for a way to enable a user of my SCADA application to save the content of a table locally. Unfortunately, all clients have access to the system only using the web-client which is served from a Citrix session, this rules out using a function like writeToFile() as the file would be stored locally on the Citrix server.
I noticed that it is possible to send emails from WinCC-OA and I was wondering if this could be an option, e.g. use writeToFile() to save the output of the table locally on the Citrix server and then send an email including the file as an attachment. The only thing is, the help file doesn't mention anything about adding attachments to an email... is this possible?
Any other ideas?
Sending emails
- leoknipp
- Posts:2928
- Joined: Tue Aug 24, 2010 7:28 pm
Re: Sending emails
Hello,
with the WinCC OA-functions to send emails it is not possible to send an attachment.
Maybe you could solve the requested functionality by uploading the file to a ftp-server where the clients have access to.
Best Regards
Leopold Knipp
Senior Support Specialist
with the WinCC OA-functions to send emails it is not possible to send an attachment.
Maybe you could solve the requested functionality by uploading the file to a ftp-server where the clients have access to.
Best Regards
Leopold Knipp
Senior Support Specialist
- fmulder
- Posts:330
- Joined: Wed Feb 03, 2010 9:46 am
Re: Sending emails
Hi Jonathan,
I recently developed this for a customer. The PVSS mail functionis talking to an SMTP server. The communication to this server is just ascii. You can make it do just anthing that you normal HTML client can do. So my advie would be : implement a new function sendEmailWithAttachments()
Look at the following website for a possible example:
http://www.gentle.it/alvise/smtp.htm
When you send a mail with attachment, then you're just passing the proper commands to the SMTP server. You do not really need a file on disk.
In my case we were sending a screenshot directly via mail (as an attachment). You can also add the bitmap 'inline'. That is : it would show up directly in the mail. This might also be an option for your email. In my case we used a HTML formatted email, to make it look a bit nicer, with screenshot or alarm tabel content (csv) as an attachment.
The only challengethat we had was the Base64 encoding of the attachment. A binary file, or actually any file that you 'attach' is encoded using a relative simple algorithm. Unfortunately, this algorithm took to much time in PVSS scripting language and I had to do the encoding in a C++ control DLL. A 1920*1200 screen took 8 seconds to encode in scripting. It is now 0 in C++. (You can tell the embeddedmodule componnt to write its contents to a file on disk. Then use the control DLL to encode this file)
Good luck
Frenk
I recently developed this for a customer. The PVSS mail functionis talking to an SMTP server. The communication to this server is just ascii. You can make it do just anthing that you normal HTML client can do. So my advie would be : implement a new function sendEmailWithAttachments()
Look at the following website for a possible example:
http://www.gentle.it/alvise/smtp.htm
When you send a mail with attachment, then you're just passing the proper commands to the SMTP server. You do not really need a file on disk.
In my case we were sending a screenshot directly via mail (as an attachment). You can also add the bitmap 'inline'. That is : it would show up directly in the mail. This might also be an option for your email. In my case we used a HTML formatted email, to make it look a bit nicer, with screenshot or alarm tabel content (csv) as an attachment.
The only challengethat we had was the Base64 encoding of the attachment. A binary file, or actually any file that you 'attach' is encoded using a relative simple algorithm. Unfortunately, this algorithm took to much time in PVSS scripting language and I had to do the encoding in a C++ control DLL. A 1920*1200 screen took 8 seconds to encode in scripting. It is now 0 in C++. (You can tell the embeddedmodule componnt to write its contents to a file on disk. Then use the control DLL to encode this file)
Good luck
Frenk
- aorange
- Posts:147
- Joined: Thu Nov 04, 2010 10:07 am
Re: Sending emails
Cheers guys, that's great... the FTP option seems straight forward but I think I would rather email the content to the user that requested it directly, it feels more user friendly. I'll have to give it a try in CONTROL and see how long it takes to encode the file... it isn't very large so hopefully it won' be too bad.
As an aside, isn't Base64 the same encoding mechanism that is used to encrypt user passwords in WinCC-OA? If I end up going this route, I might as well build a feature for users to recover forgotten passwords =)
As an aside, isn't Base64 the same encoding mechanism that is used to encrypt user passwords in WinCC-OA? If I end up going this route, I might as well build a feature for users to recover forgotten passwords =)
- Gertjan van Schijndel
- Posts:634
- Joined: Mon Aug 02, 2010 10:37 am
Re: Sending emails
You could also look at how the 'Diagnostics Tool' sends e-mails with attachments. It uses 'Free console smtp client' for this purpose.
For the base64 encoding of a blob you could use the 'xmlrpcEncodeValue' function and remove the heading '' and trailing ''.
For the base64 encoding of a blob you could use the 'xmlrpcEncodeValue' function and remove the heading '' and trailing ''.
- leoknipp
- Posts:2928
- Joined: Tue Aug 24, 2010 7:28 pm
Re: Sending emails
Hello,
for the password encryption the CTRL-function crypt() is used.
There is no functionality available to decrypt the passwords.
Enclosed you'll find the description for this function copied from the online-help:
The function crypt() encrypts the transferred text (max. 63 characters are taken into consideration) in accordance with the "Proposed Federal Information Processing Data Encryption Standard". crypt() is used in WinCC OA for encrypting passwords. Passwords are stored in the database in encrypted form and can only be read again in encrypted form.
Best Regards
Leopold Knipp
Senior Support Specialist
for the password encryption the CTRL-function crypt() is used.
There is no functionality available to decrypt the passwords.
Enclosed you'll find the description for this function copied from the online-help:
The function crypt() encrypts the transferred text (max. 63 characters are taken into consideration) in accordance with the "Proposed Federal Information Processing Data Encryption Standard". crypt() is used in WinCC OA for encrypting passwords. Passwords are stored in the database in encrypted form and can only be read again in encrypted form.
Best Regards
Leopold Knipp
Senior Support Specialist
- mkoller
- Posts:741
- Joined: Fri Sep 17, 2010 9:03 am
Re: Sending emails
Oh well ... poor Windows users ...
Sending email (in a standards conforming, correct way) can be quite complex (depending on your infrastructure). I'd suggest you do not try to reinvent yet another mail sending tool but instead use what's already available on a system (well ... at least there is a lot available on a sensible operating system).
On Linux you would simply use the "mail" commandline tool.
Sending email (in a standards conforming, correct way) can be quite complex (depending on your infrastructure). I'd suggest you do not try to reinvent yet another mail sending tool but instead use what's already available on a system (well ... at least there is a lot available on a sensible operating system).
On Linux you would simply use the "mail" commandline tool.
- tmalone
- Posts:192
- Joined: Mon Nov 22, 2010 11:21 pm
Re: Sending emails
I found the method used by the diagnostic tool to be quite good. It will send out a simple email or one with an attachment. That little SNMP command line tool (/bin/sendEmail.exe) seems to work well with windows (thanks for your Linux point of view, Martin).
In the US, the sendSMS(), emSendMail() and the calls in email.ctl lib are all too old for modern systems (I can't get a single one of them to work at all). Most of our customers want to bypass the local company outlook emails and go to the internet for solutions like hotmail, gmail and yahoo. I have tested both hotmail and yahoo. I discovered that the SNMP servers for gmail are at a different port than 25, so it fails. But, an hotmail account can send to a gmail address, etc.
I also discovered some nice code that CERN had written for emailing alarms (https://j2eeps.cern.ch/wikis/display/EN ... rmIsRaised). This uses the old emSendMail() call so I could not get it to work at all.
Here is my question? The command line tool technique used by the diagnostic tool works great, but it is not very fast because it relies on a file creation to check for completion. This would not be good to get stuck in a thread by the alarm class script sitting on the email send feature. So, I am looking at filling a dyn_string with the messages in the alarm class script, and then just purging the dyn_string using a standard CTL manager and maybe a timer? This way the time it takes to interact with the email system is independent from the alarm activity.
Our customers really want to use SMS (called Texting in the US). I know that we can send and email to a phone text by using a combination of the phone number and cell phone vendor. The existence of an SMS server for a specific or ANY cell phone company seems to be nowhere. I can think of only using the email technique for this.
Another question? If I can recognize the instanceID of the alarm, is it possible for a reply to ack the alarm? I have not looked deeply into this, but it would seem possible. My fall-back position with the customers is to use the UltraLight client to get a full alarm viewer and they can ack alarms directly.
Thanks to the community for commenting on this.
Todd Malone
Siemens HMI CoC
Montana, USA
In the US, the sendSMS(), emSendMail() and the calls in email.ctl lib are all too old for modern systems (I can't get a single one of them to work at all). Most of our customers want to bypass the local company outlook emails and go to the internet for solutions like hotmail, gmail and yahoo. I have tested both hotmail and yahoo. I discovered that the SNMP servers for gmail are at a different port than 25, so it fails. But, an hotmail account can send to a gmail address, etc.
I also discovered some nice code that CERN had written for emailing alarms (https://j2eeps.cern.ch/wikis/display/EN ... rmIsRaised). This uses the old emSendMail() call so I could not get it to work at all.
Here is my question? The command line tool technique used by the diagnostic tool works great, but it is not very fast because it relies on a file creation to check for completion. This would not be good to get stuck in a thread by the alarm class script sitting on the email send feature. So, I am looking at filling a dyn_string with the messages in the alarm class script, and then just purging the dyn_string using a standard CTL manager and maybe a timer? This way the time it takes to interact with the email system is independent from the alarm activity.
Our customers really want to use SMS (called Texting in the US). I know that we can send and email to a phone text by using a combination of the phone number and cell phone vendor. The existence of an SMS server for a specific or ANY cell phone company seems to be nowhere. I can think of only using the email technique for this.
Another question? If I can recognize the instanceID of the alarm, is it possible for a reply to ack the alarm? I have not looked deeply into this, but it would seem possible. My fall-back position with the customers is to use the UltraLight client to get a full alarm viewer and they can ack alarms directly.
Thanks to the community for commenting on this.
Todd Malone
Siemens HMI CoC
Montana, USA
- Gertjan van Schijndel
- Posts:634
- Joined: Mon Aug 02, 2010 10:37 am
Re: Sending emails
Todd, are you saying that you cannot send a text to a cell phone of a different phone company? Because here every cell phone is signed in at the sms centrale of its phone company and can send texts to every phone (even to fixed lines).
During our tests we have noticed that every cell phone manufacturer uses its own dialect of the AT commands for texting. But we have always got it to work with some modifications to the sms.ctl script. For our tests we did not have a real cell phone modem, but used a normal cell phone.
If you have the atime of an alarm, you can ack the alarm with the '_ack' attribute for non-multi-instance alerts and for multi-instance alerts you can use the '_event' attribute.
During our tests we have noticed that every cell phone manufacturer uses its own dialect of the AT commands for texting. But we have always got it to work with some modifications to the sms.ctl script. For our tests we did not have a real cell phone modem, but used a normal cell phone.
If you have the atime of an alarm, you can ack the alarm with the '_ack' attribute for non-multi-instance alerts and for multi-instance alerts you can use the '_event' attribute.
- tmalone
- Posts:192
- Joined: Mon Nov 22, 2010 11:21 pm
Re: Sending emails
Gertjan,
The issue is that in the US, there is no "SMS Server" as the examples in the ETM help suggest. I have not tried a GSM modem due to the cost and contract to get into a system. In the states very few phone companies allow month-to-month for this sort of service. The phone companies use formats like 1234567889@vmail.com for a Verizon phone to send an SMS.
the /bin/sendEmail.exe works great. You can even use your existing yahoo, Hotmail or gmail account to be the "sender" so you don't have to have a local SMTP email server. The only issue is that it is not very fast, because you have to spawn a command line to run it. It works in both Windows and Linux.
The issue is that in the US, there is no "SMS Server" as the examples in the ETM help suggest. I have not tried a GSM modem due to the cost and contract to get into a system. In the states very few phone companies allow month-to-month for this sort of service. The phone companies use formats like 1234567889@vmail.com for a Verizon phone to send an SMS.
the /bin/sendEmail.exe works great. You can even use your existing yahoo, Hotmail or gmail account to be the "sender" so you don't have to have a local SMTP email server. The only issue is that it is not very fast, because you have to spawn a command line to run it. It works in both Windows and Linux.