Support forum
Hello Sam,
If you are not a programmer then I don't recommend using scripts in Diafaan SMS Server. To get the example scripts to work you need at least a basic understanding of the C# or Visual Basic.Net programming languages.
Regards, Henk
12:09 pm
hello, im very new to using the sms server. i would like to send an sms to numbers stored in a csv file.i have downloaded the scripting pack but am so clueless on how i should make it work. can anyone please help
11:59 pm
It worked ok, thanks. I had to make minor changes to the code.
The script snippet is based on the headers of the 'SendMessagesFromCSVFile.cs' script from the Scripting Pack. As a minimum you have to add the following lines from the the 'SendMessagesFromCSVFile.cs' script to your own script:
- On line 3:
// AddReference Microsoft.VisualBasic.dll
- On lines 9 and 10:
using System.IO;
using Microsoft.VisualBasic.FileIO;
Regards, Henk
6:34 pm
Hello, now it says that this "TextFieldParser" cannot be found.
I also had to change this line to work, Does that have to do with the "TextFieldParser" error ?
if (System.IO.File.Exists(csvNumbersFileName))
sorry, Im not a programmer.
Thanks
7:29 pm
Thanks for your response, the script outputs this error on line 27.
Unexpected symbol `=' in class, struct, or interface member ...
that would be here:
csvFileName = @"c:\temp
umbers.csv";
Thanks again
The following script snippet reads a CSV file when a message is received from number '+5555555555' and forwards the message to all numbers in the first field of each row of the CSV file. The snippet is based on the 'AddReference' and 'using' header definitions in the 'SendMessagesFromCSVFile.cs' script example file.
private string csvNumbersFileName = @"c:\temp\numbers.csv"; private void OnMessageReceived(string fromAddress, string toAddress, string message, string messageType, string messageId, string smsc, string pdu, string gateway, DateTime sendTime, DateTime receiveTime) { try { if (fromAddress == "+5555555555") { if (File.Exists(csvNumbersFileName)) { using (TextFieldParser parser = new TextFieldParser(csvNumbersFileName)) { parser.TextFieldType = FieldType.Delimited; parser.SetDelimiters(","); while (!parser.EndOfData) { //Processing row string[] fields = parser.ReadFields(); // The first field in the row is the destination number if (fields.Length >= 1) { PostSendMessage(fields[0], "", message, "", "", "", "", 0); } } } } } } catch (Exception ex) { PostEventLog(ex.Message, ex.ToString(), EventLog.Error); } }
Regards, Henk
3:34 am
Hello, I managed to accomplished what I wanted. I adapted the default code to received a message,
filter it and forward it to different numbers.
I have the number list store in a csv file, It would be great to read de csv file, that only contains
cell numbers, and forward the message to that list, so I dont have to add each number manually.
Here is the code:
private void OnMessageReceived(string fromAddress, string toAddress, string message, string messageType,
string messageId, string smsc, string pdu, string gateway,
DateTime sendTime, DateTime receiveTime)
{
if ( fromAddress == "+5555555555") {
PostSendMessage("22222222222", fromAddress, message, messageType, "", "", "", 0);
PostSendMessage("11111111111", fromAddress, message, messageType, "", "", "", 0);
//
// TODO: Add code to handle received SMS messages
// e.g.
//PostSendMessage(fromAddress, "", "We have received your message", "sms.text", "", "", "", 0);
//
} }
I hope you can help,
Thanks
Hello Leo,
Diafaan SMS Server does not have the built-in functionality to import SMS messages from a CSV file and send them. But it is possible to use a Scripting Connector with a custom script to import CSV files.
You can find an example C# script to import CSV files in the Scripting Pack on the download page. The script is called 'SendMessagesFromCSVFile.cs', it is located in the 'ConnectorScripts' folder of the ZIP file.
Regards, Henk
Most Users Ever Online: 529
Currently Online:
5 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Member Stats:
Guest Posters: 672
Members: 0
Moderators: 0
Admins: 1
Forum Stats:
Groups: 2
Forums: 3
Topics: 1141
Posts: 3899
Newest Members:
, Henk HelmantelAdministrators: Henk Helmantel: 1488