How to use Forms10g to send mass email to users via MS Outlook?
Does anyone has tried to write a Forms that retrieve emails from a database schema and then send mass emails to these users viad Microsoft Outlook? If yes, would you like to share your valuable experience with us?
i would be easier to depend on database packages for achieving this result, whether you create procedures or database triggers, you can still invoke these construct form your form. If you database is a 10g database, it is easier to handle mass email since there is an already built-in package for this.
below is an example
Using UTL_MAIL (only for Oracle 10g)
make sure that the UTL_MAIL package is installed
SQL>start utlmail.sql
SQL>start prvtmail.plb
both can be found under $ORACLE_HOME/rdbms/admin
utl_mail.send(
sender IN VARCHAR2 CHARACTER SET ANY_CS,
recipients IN VARCHAR2 CHARACTER SET ANY_CS,
cc IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL,
bcc IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL,
subject IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL,
message IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT NULL,
mime_type IN VARCHAR2 CHARACTER SET ANY_CS DEFAULT 'text/plain;
charset=us-ascii',
priority IN PLS_INTEGER DEFAULT 3);
Example
declare
vSend VARCHAR2(30) := '[email protected]';
vSubj VARCHAR2(50) := '10g new mail package';
vMesg VARCHAR2(4000);
vMType VARCHAR2(30) := 'text/plain; charset=us-ascii';
BEGIN
vmesg:= 'Hello mail 10g worked';
utl_mail.send(vSend, '[email protected]', NULL, NULL, vSubj,
vMesg, vMType, NULL);
END ;
Note: for this to work, you need to set the SMTP Server
SQL>ALTER SYSTEM SET smtp_out_server ='smtp.realsoft-me.com' scope=spfile ; -- added Aug 15,2005
-- Use your own smtp server name
Re-bounce the instance for the changes to take place
If you database is oracle 9i, then you have to depend on packages like UTL_SMTP , UTL_TCP. i have another example that uses the sames sample code that Mark refered to and you can find such example at my website
http://www.e-ammar.com/Oracle_TIPS/oramail.htm
The code my seem a bit complex, but you many not need to use it all, additionally, it makes a difference if you are going to use attachments or not.
hope this helps
Ammar Sajdi
www.e-ammar.com
www.palco-me.com
www.realsoft-me.com
Amman - Jordan Oracle certified partner
Partner, CEO and consultant
Similar Messages
-
How to use Add_Delivery_Option to send an email to multiple recipients
I have the following code before i submit a concurrent request:
B_Delivery_Success := Fnd_Request.Add_Delivery_Option(
'E', -- EMAIL
'Enter subject', -- SUBJECT
'[email protected]', -- FROM
'[email protected]' -- TO
,NULL -- CC
which correctly sends an email with attachment. However i need to send the email to multiple recipients. How can you enter multiple names against the 'TO' parameter. I know that i can repeat this again and again with a different email address each time, however there must be away to use this code once with multiple addresses?
Edited by: user974582 on 09-Oct-2012 01:23Not sure about the API but there are other ways to achieve it i.e. through alerts.. You can refer below
Can Concurrent Request Notifications Work With A Group Email ID [ID 1096850.1]
Cheers,
ND -
How to use FM SO_DOCUMENT_REPOSITORY_MANAGER send mail with CC.
Dear Experts:
Please help me. How to use FM SO_DOCUMENT_REPOSITORY_MANAGER send mail with CC.
My Program code is as follow:
*Send the mail.
tb_receipients-recnam = 'BAITZ'.
tb_receipients-recesc = 'B'.
tb_receipients-sndex = 'X'.
tb_receipients-att_fix ='X' .
APPEND tb_receipients.
CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
EXPORTING
method = wa_method1
office_user = wa_owner
ref_document = wa_ref_document
new_parent = wa_new_parent
IMPORTING
authority = wa_authority
TABLES
objcont = tb_objcnt
objhead = tb_objhead
objpara = tb_objpara
objparb = tb_objparb
recipients = tb_receipients
attachments = tb_attachments
references = tb_references
files = tb_files
CHANGING
document = wa_document
header_data = wa_header.
endform. " send_mail
By the why, tb_receipients-recnam = 'BAITZ'. What's the meaning of 'BAITZ'? Thanks!you can use FM SO_NEW_DOCUMENT_SEND_API1
WA_RECV TYPE SOMLRECI1,
IT_RECV TYPE STANDARD TABLE OF SOMLRECI1.
wa_recv-receiver = 'TO email address'.
wa_recv-rec_type = 'U'.
wa_recv-com_type = 'INT'.
APPEND wa_recv TO it_recv.
CLEAR wa_recv."To Recipient
wa_recv-receiver = 'CC email address'.
wa_recv-rec_type = 'U'.
wa_recv-com_type = 'INT'.
wa_recv-copy = 'X'.
APPEND wa_recv TO it_recv.
CLEAR wa_recv. "CC Recipient
wa_recv-receiver = 'BCC email address'.
wa_recv-rec_type = 'U'.
wa_recv-com_type = 'INT'.
wa_recv-blind_copy = 'X'.
APPEND wa_recv TO it_recv.
CLEAR wa_recv. "BCC Recipient -
How to use a nice format for email [From]
hi there,
Does anyone know how to use a nice format for email? Currently my Auto-System sends an email to the client with the account name ([email protected]) and I want to change it to a nice format such as 'Auto-Response'
anyone?
Ppranyone?
-
HELP. Using iCal to send timed emails - I used to be able to do this...
Ok - there's a chance I've gone completly mad - or I just dreamt this - but: Once upon a time I used iCal to send timed emails (with Mail) to outside addresses without the emails looking like they came from iCal.
I did this for things like 'calling' in sick to work (therefor looking like I was up at 8:15 being ill, instead of sleeping comfortably in hung over splendor) or sending out parts of work throughout the workday (instead of when I'd actually completed them at three in the morning).
This was very useful.
I just can't now figure out how I did this.
Has one of the iCal updates removed this function? Is there something obvious I've forgotten?
I seem to remember using iCal to trigger a file that in turn sent the email - but again I can't trust my memory.
Anyone have any hints or ideas? I'm driving my self mad on this one.Neal,
I am in the same predicament. I would essentially like to accomplish the same deal, as seen below. . . (from another forum that went unanswered.)
I use iCal (1.5.5/ 2.0.3) currently but own Entourage (11.2.1) as well. I have clients that I service on a weekly or biweekly basis whose appointments are in my iCal; I call and remind them the day before. The majority of these people are great about checking email. I would like to set up an automated email reminder which is sent to them for each appointment, two days in advance that does not contain an .ics file. Many times my clients' email app has junked the message due to the small attachment. Others don't want to open a file when they don't know what it is.
Predetermined timed stamped/Automated iCal events are possible aren't they?! If not, do I have to move over to :dreaded Entourage? -
Introduction
There is a scenario that the data in the report changes infrequently, so the users want to be informed and get the most updated data once the data changes. By default, report server always run the report with the most recent data. Is there a way that we
can subscribe the report, so that we can send an email to users when the data in the report has been changed?
Solution
To achieve this requirement, we can create a subscription for the report, then create a trigger in the table which including the report data. When this table has data insert, update or delete, it will be triggered and execute the subscription to send email
to users.
In the Report Manager, create a subscription for the report and make it only execute one time.
When we create a subscription, a corresponding SQL Agent job will be created. Then we can use the query below to find out the job based on ScheduleId:
-- List all SSRS subscriptions
USE [ReportServer]; -- You may change the database name.
GO
SELECT USR.UserName AS SubscriptionOwner
,SUB.ModifiedDate
,SUB.[Description]
,SUB.EventType
,SUB.DeliveryExtension
,SUB.LastStatus
,SUB.LastRunTime
,SCH.NextRunTime
,SCH.Name AS ScheduleName
,RS.ScheduleId
,CAT.[Path] AS ReportPath
,CAT.[Description] AS ReportDescription
FROM dbo.Subscriptions AS SUB
INNER JOIN dbo.Users AS USR
ON SUB.OwnerID = USR.UserID
INNER JOIN dbo.[Catalog] AS CAT
ON SUB.Report_OID = CAT.ItemID
INNER JOIN dbo.ReportSchedule AS RS
ON SUB.Report_OID = RS.ReportID
AND SUB.SubscriptionID = RS.SubscriptionID
INNER JOIN dbo.Schedule AS SCH
ON RS.ScheduleID = SCH.ScheduleID
ORDER BY USR.UserName
,SUB.ModifiedDate ;
Create a trigger in the table which including the report data.
CREATE TRIGGER reminder
ON test.dbo.users
AFTER INSERT, UPDATE, DELETE
AS
exec [ReportServer].dbo.AddEvent @EventType='TimedSubscription', @EventData='b64ce7ec-d598-45cd-bbc2-ea202e0c129d'
Please note that the command ‘exec [ReportServer].dbo.AddEvent @EventType='TimedSubscription', @EventData='b64ce7ec-d598-45cd-bbc2-ea202e0c129d'’ is coming from the job properties. We can go to SQL Server Agent Jobs, right-click the corresponding job to open
the Steps, copy the step command, and then paste it to the query.
Then when the user table has data insert, update or delete, the trigger will be triggered and execute the subscription to send email to users.
References:
Subscriptions and Delivery (Reporting Services)
Internal Working of SSRS Subscriptions
SQL Server Agent
Applies to:
Reporting Services 2005
Reporting Services 2008
Reporting Services 2008 R2
Reporting Services 2012
Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.Thanks,
Is this a supported scenario, or does it use unsupported features?
For example, can we call exec [ReportServer].dbo.AddEvent @EventType='TimedSubscription', @EventData='b64ce7ec-d598-45cd-bbc2-ea202e0c129d'
in a supported way?
Thanks! Josh -
How to use logger to send any output instead of the console?
How to use logger to send any output instead of the console?
How to use logger to send any output instead of the
console?There are three commonly used logger inferfaces, the log4j, the java.util.loging and the Commons logging (which works with either.)
You create a logger object, generally one for each class. Normally a private static variable points to it and it has a name equal to the FQN of the class.
e.g.
package org.widget;
public class MyClass {
private static Logger log = Logger.getLogger("org.widget.MyClass");That's the java.uitil.Logger formula.
Then there are method on the logger to call for various kinds of output. There' are different logging levels, priorities like SEVERE or DEBUG. When running the logs are configured to ignore messages of less than a set priority.
You can also pass an Exception or Error to the logger which will log the stack trace. -
Adding prompts dynamically and then send the results to users via email
Hi,
We have to schedule the reports for auto delivery to users at a specific time period. Please, tell me the mechanism to schedule them and how to assign prompt values to them. Currently, the reports are run by users by selecting prompts from the dashboard. If we schedule them, we will have to add some of these prompts dynamically and then send the results to users via email.
Thanks in advance!Hi,
I haven't tested it myself...but may be the following steps can help you.
Fill some session variables depending on the the name of the user who logs in (this can be done easily be creating different session variables and put some executing order in it)
Then you use these session variables as default values for your prompts. So the report will be executed making use of this default values.
And by scheduling your ibot..you can send it by mail.
I don't know if it's this what you're looking for...probably you have to base your prompt values depending on the users that are selected in your ibot?
Hope it can help y ou in some way or another...
KR,
A -
Need Help in sending Private Email when user clicks Oracle Password Reset
How to send an email to user marked as PRIVATE and Confidential when they hit the Oracle Password Reset Link.
user11986391 wrote:
How to send an email to user marked as PRIVATE and Confidential when they hit the Oracle Password Reset Link.What do you mean by private and confidential?
Reset Password Functionality FAQ [ID 399766.1]
How to Modify The Password Reset Statement for the UMXUPWD.wft Workflow [ID 420236.1]
How to Change the Text of Instructions in the "Reset Password" Screen? [ID 762798.1]
How to open customized page when click on "Forgot Password" URL ? [ID 556454.1]
https://forums.oracle.com/forums/search.jspa?threadID=&q=Password+AND+Forgot&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
Thanks,
Hussein -
Sending an email to users from abap program
Hi experts ,
How to send an email to users from abap program ...
i need full coding please..so that i can copy and paste it in my program.
Thank you in advance.
Rajasekhar.PHi Venkat
check the below simple code to convert spool to HTML and email it
data: list type table of abaplist with header line.
data: htmllines type table of w3html with header line.
data: maildata like sodocchgi1.
data: mailtxt like solisti1 occurs 10 with header line.
data: mailrec like somlrec90 occurs 0 with header line.
start-of-selection.
Produce a list
do 100 times.
write:/ sy-index, at 30 sy-index, at 50 sy-index.
enddo.
Save the list
call function 'SAVE_LIST'
tables
listobject = list
exceptions
list_index_invalid = 1
others = 2.
Convert the list
call function 'WWW_LIST_TO_HTML'
tables
html = htmllines.
Send mail
maildata-obj_name = 'TEST'.
maildata-obj_descr = 'Test Subject'.
loop at htmllines.
mailtxt = htmllines.
append mailtxt.
endloop.
mailrec-receiver = '[email protected]'.
mailrec-rec_type = 'U'.
append mailrec.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_data = maildata
document_type = 'HTM'
put_in_outbox = 'X'
tables
object_header = mailtxt
object_content = mailtxt
receivers = mailrec
exceptions
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
others = 8.
if sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif. -
How to use the same POWL query for multiple users
Hello,
I have defined a POWL query which executes properly. But if I map the same POWL query to 2 portal users and the 2 portal users try to access the same page simultaneously then it gives an error message to one of the users that
"Query 'ABC' is already open in another session."
where 'ABC' is the query name.
Can you please tell me how to use the same POWL query for multiple users ?
A fast reply would be highly appreciated.
Thanks and Regards,
SandhyaBatch processing usually involves using actions you have recorded. In Action you can insert Path that can be used during processing documents. Path have some size so you may want to only process document that have the same size. Look in the Actions Palette fly-out menu for insert path. It inserts|records the current document work path into the action being worked on and when the action is played it inserts the path into the document as the current work path..
-
Need to generate a script which will sends an email to users reg cube statu
Hi All,
Once the cube gets loaded successfully an email has to sent out automatically thru maxl to users saying that cubes has loaded as off today's date. Could you please help me is their any script available which will automatically sends an email to users that would be helpfull for me.
Thanks in Advance,
Raj.Raj,
Here's a good start:
http://www.network54.com/Forum/58296/thread/1196781565/Maxl+Scripts+to+send+out+email+notifications
http://www.network54.com/Forum/58296/thread/1106766086/Essbase+Script+Box+-TellingUser+when+the+previous+script+was+run
http://www.network54.com/Forum/58296/thread/1167815846/Email+notification+through+MaxL
http://www.network54.com/Forum/58296/thread/1193233965/Automate+the+Email+Notification
Regards,
Cameron Lackpour -
How to use rule and send the same email to multiple recipents
Hi,
My requirement is to send the workitem to the multiple recipents. one of my reiend suggest me to use the rule but i don't know how to use that .
can any one of you suggest me how to use rule in workflow.
Also i want to send the same email to multiple recipent .how can i do it by using the multiline variable...please advice me with example if possible..
Note :- Is it necessary to saparate the email id with comma or i will add all the email next one another..
Please suggest.
Thanks in advance ,
AnandHi Anand,
I would suggest you first follow the guidelines of the forum and a little searching. One of your questions has been asked just a few threads below.
Regards,
Martin -
How to use UTL_SMTP to send email with existing file attachment
Hello! I am trying to create a pl/sql procedure that lets me send an email and include an existing file to a email address. So far, I found information on how to send a file and create an attachment with information I put in the procedure. This is NOT what I'm trying to do. I'm trying to send an email and include an attachment for a file that already exists. I need the pre-existing file to be sent to the email recipient.
This is how far I've gotten, but this only allows me to CREATE an attachment with the information I put in it from the procedure. I got it from the following site:
http://www.orafaq.com/wiki/Send_mail_from_PL/SQL
DECLARE
v_From VARCHAR2(80) := '[email protected]';
v_Recipient VARCHAR2(80) := '[email protected]';
v_Subject VARCHAR2(80) := 'Weekly Invoice Report';
v_Mail_Host VARCHAR2(30) := 'mail.mycompany.com';
v_Mail_Conn utl_smtp.Connection;
crlf VARCHAR2(2) := chr(13)||chr(10);
BEGIN
v_Mail_Conn := utl_smtp.Open_Connection(v_Mail_Host, 25);
utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);
utl_smtp.Mail(v_Mail_Conn, v_From);
utl_smtp.Rcpt(v_Mail_Conn, v_Recipient);
utl_smtp.Data(v_Mail_Conn,
'Date: ' || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf ||
'From: ' || v_From || crlf ||
'Subject: '|| v_Subject || crlf ||
'To: ' || v_Recipient || crlf ||
'MIME-Version: 1.0'|| crlf || -- Use MIME mail standard
'Content-Type: multipart/mixed;'|| crlf ||
' boundary="-----SECBOUND"'|| crlf ||
crlf ||
'-------SECBOUND'|| crlf ||
'Content-Type: text/plain;'|| crlf ||
'Content-Transfer_Encoding: 7bit'|| crlf ||
crlf ||
'This is a test'|| crlf || -- Message body
'of the email attachment'|| crlf ||
crlf ||
'-------SECBOUND'|| crlf ||
'Content-Type: text/plain;'|| crlf ||
' name="ap_inv_supplier_cc10.txt"'|| crlf ||
'Content-Transfer_Encoding: 8bit'|| crlf ||
'Content-Disposition: attachment;'|| crlf ||
' filename="ap_inv_supplier_cc10.txt"'|| crlf ||
crlf ||
'TXT,file,attachment'|| crlf || -- Content of attachment (THIS IS MY PROBLEM! I NEED TO BE ABLE TO ATTACH AN EXISTING FILE, NOT CREATE A NEW ONE)
crlf ||
'-------SECBOUND--' -- End MIME mail
utl_smtp.Quit(v_mail_conn);
EXCEPTION
WHEN utl_smtp.Transient_Error OR utl_smtp.Permanent_Error then
raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
END;
/First, you must create a directory object
create directory ORALOAD as '/home/ldcgroup/ldccbc/'
/Study the Prerequisites in the link I posted above, or else you will not be able to read/write files from the above directory object
"fname" relates to the file name that you read from.
In the code below, it is also the name of the file that you are attaching.
Although they can be different!
l_Output is the contents of the file.
declare
vInHandle utl_file.file_type;
flen number;
bsize number;
ex boolean;
l_Output raw(32767);
fname varchar2(30) := 'ap_inv_supplier_cc10.txt';
vSender varchar2(30) := '[email protected]';
vRecip varchar2(30) := '[email protected]';
vSubj varchar2(50) := 'Weekly Invoice Report';
vAttach varchar2(50) := 'ap_inv_supplier_cc10.txt';
vMType varchar2(30) := 'text/plain; charset=us-ascii';
begin
utl_file.fgetattr('ORALOAD', fname, ex, flen, bsize);
vInHandle := utl_file.fopen('ORALOAD', fname, 'R');
utl_file.get_raw (vInHandle, l_Output);
utl_file.fclose(vInHandle);
utl_mail.send_attach_raw(sender => vSender
,recipients => vRecip
,subject => vsubj
,attachment => l_Output
,att_inline => false
,att_filename => fname);
end;
/ -
How to use java to send emails
Hi,
I am having problems trying to send an email using java. No idea what is going on because it looks fine. Can anyone give any insight?
Cheers
Robert
import java.awt.event.*;
import java.awt.*;
import java.net.*;
import java.io.*;
import javax.swing.*;
* JEmail.java
* @author Robert Venning 18/09/2005
* @version 1.0
public class JEmail extends JFrame implements ActionListener{
private static final long serialVersionUID = 1L;
final int SMTP_PORT = 25;
JLabel fromLabel = new JLabel("From: ");
JLabel toLabel = new JLabel("To: ");
JLabel ccLabel = new JLabel("CC: ");
JLabel subjectLabel = new JLabel("Subject: ");
JTextField from = new JTextField(20);
JTextField to = new JTextField(20);
JTextField cc = new JTextField(20);
JTextField subject = new JTextField(20);
JTextArea message = new JTextArea(10,30);
JScrollPane scrollPane = new JScrollPane(message);
JButton send = new JButton("Send");
public JEmail(){
super("Email Program");
JPanel mainPane = new JPanel();
JPanel pane = new JPanel();
JPanel fromPane = new JPanel();
JPanel toPane = new JPanel();
JPanel ccPane = new JPanel();
JPanel subjectPane = new JPanel();
mainPane.setLayout(new FlowLayout());
pane.setLayout(new GridLayout(4,1));
fromPane.add(fromLabel);
fromPane.add(from);
toPane.add(toLabel);
toPane.add(to);
ccPane.add(ccLabel);
ccPane.add(cc);
subjectPane.add(subjectLabel);
subjectPane.add(subject);
pane.add(fromPane);
pane.add(toPane);
pane.add(ccPane);
pane.add(subjectPane);
mainPane.add(pane);
mainPane.add(scrollPane);
mainPane.add(send);
setContentPane(mainPane);
send.addActionListener(this);
public static void main(String[] args) {
JFrame aFrame = new JEmail();
aFrame.setSize(350, 400);
aFrame.setVisible(true);
public void actionPerformed(ActionEvent event){
try{
PrintWriter writer = new PrintWriter(new FileWriter("log.txt"));
String input, output;
Socket s = new Socket("mail.tpg.com.au", SMTP_PORT);
BufferedReader in = new BufferedReader
(new InputStreamReader(s.getInputStream()));
BufferedWriter out = new BufferedWriter
(new OutputStreamWriter(s.getOutputStream()));
output = "HELO theWorld" + "\n";
out.write(output);
out.flush();
System.out.print(output);
writer.println(output);
input = in.readLine();
System.out.println(input);
// writer.println(input);
output = "MAIL FROM: <" + from.getText() + ">" + "\n";
out.write(output);
out.flush();
System.out.print(output);
writer.println(output);
input = in.readLine();
System.out.println(input);
// writer.println(input);
output = "RCPT TO: <" + to.getText() + ">" + "\n";
out.write(output);
out.flush();
System.out.print(output);
writer.println(output);
input = in.readLine();
System.out.println(input);
// writer.println(input);
output = "DATA" + "\n";
out.write(output);
out.flush();
System.out.print(output);
writer.println(output);
input = in.readLine();
System.out.println(input);
// writer.println(input);
output = "Subject: " + subject.getText() + "\n";
out.write(output);
out.flush();
System.out.print(output);
writer.println(output);
output = "From: Robert Venning <" + from.getText() + ">" + "\n";
out.write(output);
out.flush();
System.out.print(output);
writer.println(output);
// message body
output = message.getText() + "\n";
out.write(output);
out.flush();
System.out.print(output);
writer.println(output);
output = ".\n";
out.write(output);
out.flush();
System.out.println(output);
writer.println(output);
output = "QUIT" + "\n";
out.write(output);
out.flush();
System.out.print(output);
writer.println(output);
input = in.readLine();
System.out.println(input);
// writer.println(input);
writer.close();
s.close();
catch(Exception exception){
exception.printStackTrace();
}Hi, floppit. For sending emails, I used the JavaMail API. Here is some code I wrote where I used JavaMail. The most relevant lines are in bold.
/* File: ListenNotifier.java
* Author: Fabricio Machado
* [email protected]
* This utility is based on the "Listen.java" tool from the Tiny OS
* java tools package, in /tinyos-1.x/tools/java/net/tinyos/tools/.
* The original application has been extended to convert raw packet data into
* a more meaningful representation of actual photo sensor readings in
* lux.
* The application checks the readings against a user-defined
* threshold, and sends email notifications when readings break the
* threshold, and also when readings dip back below the threshold.
* Currently, the code is only fit to handle packets from the Tiny OS
* nesc application OscilloscopeRF.nc. The code gets the packet data
* by connecting via TCP to a Tiny OS java tool called "Serial Forwarder."
* "Serial Forwarder" takes packets from the base station, and forwards
* them to TCP port 9001.
* Below is UC Berkeley's copyright disclaimer regarding the original code.
* | |
* | |
* | |
* | |
* __| |__
* v
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
import java.util.Properties;
import java.io.*;
import java.net.*;
import net.tinyos.packet.*;
import net.tinyos.util.*;
import net.tinyos.message.*;
import javax.mail.internet.*;
import javax.mail.*;
import java.util.*;
public class ListenNotifier{
public static void main(String args[]) throws IOException, MessagingException {
int i;
int j = 0;
Integer threshold=0;
String to="";
String timeStamp;
// Check to see if user is running the program correctly.
// If -T option is not used, a default value of 250 lux is
// set as threshold . . .
switch (args.length){
case 0:
System.err.println("usage: java ListenNotifier < EmailAddress1 > < EmailAddress2 > . . . -T < Threshold >\n");
System.exit(2);
break;
case 1:
to = args[j];
threshold = 250;
break;
default:
if (args[args.length-2].equals("-T")){
threshold = threshold.valueOf(args[args.length-1]);
to = args[0];
while(!args[j+1].equals("-T")){
to = to + " " + args[j+1];
j++;
break;
else{
j = 0;
threshold = 250;
to = args[j];
while((j + 1) < args.length){
to = to + " " + args[j+1];
j++;
System.out.printf("Mailing list is: %s\n", to);
break;
// Connect to the Serial Forwarder on TCP port 9001 . . .
PacketSource reader = BuildSource.makeSF("192.168.0.12",9001);
// Check to see if connection to Serial Forwarder successful . . .
if (reader == null) {
System.err.println("Invalid packet source (check your MOTECOM environment variable)");
System.exit(2);
try {
// Use JavaMail API methods to set up an
// email session . . .
Properties props = System.getProperties();
Session session = Session.getInstance(props, null);
javax.mail.Message message = new MimeMessage(session);
// Open the packet source . . .
reader.open(PrintStreamMessenger.err);
// Set a threshold boolean to be used so
// email is sent only once after threshold
// is exceeded.
Boolean limit = false;
for (;;) {
// The node ID field in the OscilloscopeRF packet
// is 2 bytes long, but all byte pairs in the packet
// are in little endian order. Thus, the bytes must
// be re-ordered. They are then converted to unsigned
// integers and added together to obtain the node ID.
byte[] packet = reader.readPacket();
Integer nodeID = (( int ) packet[5] & 0xFF) + ((( int ) packet[6] & 0xFF)<<8);
System.out.printf("Packet from node %d . . . \n", nodeID);
// Begin extracting data payload of sensor readings,
// which are stored in the last 20 bytes of the packet . . .
for (i = 0; i <= 9; i++){
// Convert reading to integer, display on screen . . .
Integer sensorData = (( int ) packet[(2*i)+11] & 0xFF) + ((( int ) packet[(2*i)+12] & 0xFF)<<8);
System.out.printf("Sample %d reading at %d lux.\n", i+1, sensorData);
// Is sensor reading above limit?
if(!limit && (sensorData >= threshold)){
limit = true;
System.out.printf("WARNING: SENSOR READING ABOVE THRESHOLD--SENDING NOTICE BY TEXT MESSAGE.\n");
// Compute a time stamp for when threshold was exceeded.
java.util.Locale locale = Locale.getDefault();
java.text.DateFormat dateFormat = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.LONG,
java.text.DateFormat.LONG, locale);
timeStamp = dateFormat.format(new java.util.Date());
// Build message and send to recipients in mailing list . . .
message.setFrom();
message.setRecipients(javax.mail.Message.RecipientType.TO, InternetAddress.parse(to, false));
message.setSubject("WARNING: NODE " + nodeID.toString() + " SENSOR READING ABOVE THRESHOLD!");
message.setText("Node " + nodeID.toString() + " sensed " + sensorData.toString() + " lux on " + timeStamp + "\n");
Transport.send(message);
System.out.printf("%s\n",timeStamp);
// Has sensor reading now dropped from above threshold to below threshold?
// Same concept as before . . .
if(limit && (sensorData < threshold)){
limit = false;
System.out.printf("READING BELOW THRESHOLD AGAIN . . . SENDING NOTICE BY TEXT MESSAGE.\n");
java.util.Locale locale = Locale.getDefault();
java.text.DateFormat dateFormat = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.LONG,
java.text.DateFormat.LONG, locale);
timeStamp = dateFormat.format(new java.util.Date());
message.setFrom();
message.setRecipients(javax.mail.Message.RecipientType.TO, InternetAddress.parse(to, false));
message.setSubject("NODE " + nodeID.toString() + " READING BELOW THRESHOLD AGAIN.");
message.setText("Node " + nodeID.toString() + " sensed " + sensorData.toString() + " lux on " + timeStamp + "\n");
Transport.send(message);
System.out.printf("%s\n",timeStamp);
System.out.println();
System.out.flush();
// Catch IOException from Tiny OS java method, and
// MessagingException from setRecipients method in JavaMail API . . .
catch (IOException e) {
System.err.println("Error on " + reader.getName() + ": " + e);
catch(MessagingException e){
System.err.println("Error in javax.mail.message.setRecipients:\n" + to);
}
Maybe you are looking for
-
My iphone 5s doesn't show in my itunes
hi my iphone 5s isnt showing my device in itunes and i have checked all my settings even tried what the internet tells me.
-
Comments in operational review
Hi All, We have been struggling with the functionality of being able to include comments when creating Operational Reviews in SSM7.5. This functionality is critical for our scorecards as it allows users to see what the Reasons for Variance is as well
-
Ever since I updated to Mountain Lion, I have blacked out text boxes. Can anyone help me? Thanx
-
Hello. How is it I can make a gradient swatch with a 90º angle (for example) a saved swatch? Whenever I have saved a gradient swatch it does not allow me to specify (or save) the angle I would like the gradient to run. So whenever I create a shape an
-
Can I save old mailbox folders from My Mac to other folders on desktop?
Can I save old mailbox folders from My Mac to other folders on desktop, so that I can refer to them later if required?