Send E-mail of selected databases to selected Mail profiles
Hi All,
I want to send e-mails to selected users from selected databases and hosts in Oracle Enterprise Manager 11g?
How do i configure this issue?
Regards,
Edited by: user5199319 on Jun 21, 2012 6:43 AM
Please follow the doc
http://docs.oracle.com/cd/E11857_01/em.111/e16790/notification.htm#BABJFFCJ
Similar Messages
-
When trying to send a mail, selecting attachement fails with no error.
I imported lots of folders form Kmail (KDE3.5/ trinity) on a previous version (don't remember which one) of Thunderbird.
All worked fine. (I was able to send a variaty of files in email attachements (.xls, .zip, .txt and also files with no extension with no trouble)
Somewhen two weeks ago I updated Thunderbird and it would not allow me to attach files to a mail I want to send.
This means: --click on the button to send a new mail.
--typing a email adress
--typing a subject
--typing 'hello' into the text field
--clicking the button to attach a file
--selecting a text file, picture, .zip, binary and click 'open' in the file selector
== nothing changes in the email window to show that a file has been attached and also on sending the mail the receiver does not receive a mail.
reverting to older version of thunderbird does not seem possible as it appears that there is no link to older packages on thunderbird downlaod site?
where did I go wrong?I doubt it's a version problem. But I don't run Linux any more.
Old versions can be found here:
http://ftp.mozilla.org/pub/mozilla.org/thunderbird/releases/ -
i forgot my answers of security questions when i select (send a mail to reset my security questions) the mail wont received to my mail box?
Read this about how to change the security questions: http://support.apple.com/kb/HT5312
If you can't use these procedures because you don't have a rescue email address you will have to contact Apple. See http://support.apple.com/kb/HT5699 -
How to create a procedure to send a mail if the Database is down?
Hi,
I have created the below procedure to send a mail if the count is less than 1300. It scheduled daily @ 15 30 hrs. Its fine.
CREATE OR REPLACE procedure SCOTT.hrsmail
is
v_count number;
begin
Select count(*) into v_count from emp;
if v_count < 1300
then
UTL_MAIL.send(sender => '[email protected]',
recipients => '[email protected]',
cc => '[email protected]',
bcc => '[email protected]',
subject => 'Testing the UTL_MAIL Package',
message => 'If you get this, UTL_MAIL package
else
null; --what you want to do here
end if ;
end;
Sometime the Database is down, so the job is not running.
How to create a procedure to send a mail if the database is down?
Pls help me. Its highly appreciated.
Thanks
Niharnihar wrote:
How to create a procedure to send a mail if the database is down?And what if the database is up, but the network down? Or the database up and mail server down? Or mail server undergoing maintenance?
There are loads of "+What if's+" - and in that respect, playing "+What if database is down..+" in this case does not make any sense. You do not use the database to monitor its own up/down status. You do not rely just on SMTP as notification protocol that the database is down.
The correct approach would be using something like SNMP as the monitoring protocol. A monitoring system that can process SNMP and perform some basic root cause analysis (e.g. network to the database server down, database server status unknown). And this system supporting notification methods like SMTP, SMS and so on. -
How to send e-mail with an attachment from remote database server.???
Hi All,
I have tried the simple mail sending and with the attachment using UTL_SMTP. But the problem is , it is sending the mail with attachment of the file name i give, it takes and creates that file and sends as attachment not from the actual file location. I am trying to attach the file which i stored in remote database server.
The following code I tried. But not worked for attachment
DECLARE
v_From VARCHAR2(80) := '[email protected]';
v_Recipient VARCHAR2(80) := '[email protected]';
v_Subject VARCHAR2(80) := 'test subject';
v_Mail_Host VARCHAR2(30) := 'pop3.somedomain.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/html;'|| crlf ||
'Content-Transfer_Encoding: 7bit'|| crlf ||
crlf ||
'some message text'|| crlf || -- Message body
'more message text'|| crlf ||
crlf ||
'-------SECBOUND'|| crlf ||
'Content-Type: text/html;'|| crlf ||
' name="Fund Authorization report"'|| crlf ||
'Content-Transfer_Encoding: 8bit'|| crlf ||
'Content-Disposition: attachment;'|| crlf ||
' filename="/usr/tmp/Test.html"'|| crlf ||
crlf ||
'HTML Attachment'|| crlf || -- Content of attachment
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;How can I attach a file which is stored in database server and send it in a mail.
Please someone help me in this.
Thanks,
Alaka.Try this code
Regards Salim.
CREATE OR REPLACE TRIGGER EmailOnServerErr AFTER SERVERERROR ON DATABASE
DECLARE
mail_conn UTL_SMTP.connection;
crlf VARCHAR2(2) := chr(13)||chr(10);
msg VARCHAR2(32760);
sid_name VARCHAR2(16);
bdump_dest VARCHAR2(128);
smtp_relay VARCHAR2(32) := 'MyMailRelay';
recipient_address VARCHAR2(64) := '[email protected]';
sender_address VARCHAR2(64) := '[email protected]';
mail_port NUMBER := 25;
log_file_handle UTL_FILE.FILE_TYPE;
log_file_dir VARCHAR2(256) := 'ERR_LOG_DIR';
log_file_name VARCHAR2(256) := 'OracleErrors.log';
maxlinesize NUMBER := 32767;
session_rec sys.v_$session%ROWTYPE;
audit_rec sys.dba_audit_trail%ROWTYPE;
auditing BOOLEAN;
LinesOfSQL BINARY_INTEGER;
offending_sql DBMS_STANDARD.ora_name_list_t;
CURSOR bdump_cur IS
SELECT TRIM(value)
FROM v$parameter
WHERE name = 'background_dump_dest'
CURSOR sid_cur IS
SELECT TRIM(instance_name)
FROM v$instance
CURSOR session_cur IS
SELECT s.*
FROM v$session s
WHERE s.sid = dbms_support.mysid
CURSOR audit_trail_cur(AUDSID IN NUMBER) IS
SELECT *
FROM dba_audit_trail
WHERE sessionid = AUDSID
BEGIN
IF (USER = 'SYSTEM' OR USER = 'SYS') THEN
-- Ignore this error
NULL;
ELSIF IS_SERVERERROR (1034) THEN
-- Ignore this error
NULL;
ELSE
-- get the sid
OPEN sid_cur;
FETCH sid_cur INTO sid_name;
CLOSE sid_cur;
-- get the location of the alert log
OPEN bdump_cur;
FETCH bdump_cur INTO bdump_dest;
CLOSE bdump_cur;
-- get the session information
OPEN session_cur;
FETCH session_cur INTO session_rec;
CLOSE session_cur;
-- get the audit_trail information if it exists
OPEN audit_trail_cur(session_rec.audsid);
FETCH audit_trail_cur INTO audit_rec;
auditing := audit_trail_cur%FOUND;
CLOSE audit_trail_cur;
IF session_rec.program = 'MyProgram.exe' THEN
NULL; -- ignore actions from MyProgram - that's where I do maintenance
ELSE
-- compose the message
msg := 'Subject: Oracle error '||' on '||sid_name||crlf;
msg := msg||'To: '||recipient_address||crlf;
msg := msg||'For more information see the alert log file located at:'||crlf;
msg := msg||bdump_dest||'/alert_'||sid_name||'.log'||crlf;
msg := msg||'or the error log file: $'||log_file_dir||'/'||log_file_name||crlf;
msg := msg||'Error Time='||TO_CHAR(SYSDATE,'DD-Mon-YYYY HH24:MI:SS')||crlf;
msg := msg||DBMS_UTILITY.FORMAT_CALL_STACK||crlf;
LinesOfSQL := sql_txt(offending_sql);
msg := msg||'Offending SQL is:'||crlf;
FOR loop_counter IN offending_sql.FIRST..offending_sql.LAST
LOOP
msg := msg||offending_sql(loop_counter);
END LOOP;
msg := msg||crlf||'----- PL/SQL Error Stack -----'||crlf;
msg := msg||DBMS_UTILITY.FORMAT_ERROR_STACK||crlf;
msg := msg||'V$SESSION.SADDR=' ||session_rec.saddr ||crlf;
msg := msg||'V$SESSION.SID=' ||session_rec.sid ||crlf;
msg := msg||'V$SESSION.SERIAL#=' ||session_rec.serial# ||crlf;
msg := msg||'V$SESSION.AUDSID=' ||session_rec.audsid ||crlf;
msg := msg||'V$SESSION.PADDR=' ||session_rec.paddr ||crlf;
msg := msg||'V$SESSION.USER#=' ||session_rec.user# ||crlf;
msg := msg||'V$SESSION.USERNAME='||session_rec.username||crlf;
msg := msg||'V$SESSION.COMMAND=' ||session_rec.command ||crlf;
msg := msg||'V$SESSION.OWNERID=' ||session_rec.ownerid ||crlf;
msg := msg||'V$SESSION.TADDR=' ||NVL(session_rec.taddr ,'Null')||crlf;
msg := msg||'V$SESSION.LOCKWAIT='||NVL(session_rec.lockwait,'Null')||crlf;
msg := msg||'V$SESSION.STATUS=' ||NVL(session_rec.status ,'Null')||crlf;
msg := msg||'V$SESSION.SERVER=' ||NVL(session_rec.server ,'Null')||crlf;
msg := msg||'V$SESSION.SCHEMA#=' ||session_rec.schema#||crlf;
msg := msg||'V$SESSION.SCHEMANAME=' ||NVL(session_rec.schemaname,'Null')||crlf;
msg := msg||'V$SESSION.OSUSER=' ||NVL(session_rec.osuser ,'Null')||crlf;
msg := msg||'V$SESSION.PROCESS=' ||NVL(session_rec.process ,'Null')||crlf;
msg := msg||'V$SESSION.MACHINE=' ||NVL(session_rec.machine ,'Null')||crlf;
msg := msg||'V$SESSION.TERMINAL=' ||NVL(session_rec.terminal ,'Null')||crlf;
msg := msg||'V$SESSION.PROGRAM=' ||NVL(session_rec.program ,'Null')||crlf;
msg := msg||'V$SESSION.TYPE=' ||NVL(session_rec.type ,'Null')||crlf;
msg := msg||'V$SESSION.SQL_ADDRESS=' ||session_rec.sql_address ||crlf;
msg := msg||'V$SESSION.SQL_HASH_VALUE=' ||NVL(TO_CHAR(session_rec.sql_hash_value) ,'Null')||crlf;
msg := msg||'V$SESSION.PREV_SQL_ADDR=' ||session_rec.prev_sql_addr||crlf;
msg := msg||'V$SESSION.PREV_HASH_VALUE='||NVL(TO_CHAR(session_rec.prev_hash_value),'Null')||crlf;
msg := msg||'V$SESSION.MODULE=' ||NVL(session_rec.module ,'Null')||crlf;
msg := msg||'V$SESSION.MODULE_HASH='||NVL(TO_CHAR(session_rec.module_hash),'Null')||crlf;
msg := msg||'V$SESSION.ACTION=' ||NVL(session_rec.action ,'Null')||crlf;
msg := msg||'V$SESSION.ACTION_HASH='||NVL(TO_CHAR(session_rec.action_hash),'Null')||crlf;
msg := msg||'V$SESSION.CLIENT_INFO='||NVL(session_rec.client_info ,'Null')||crlf;
msg := msg||'V$SESSION.FIXED_TABLE_SEQUENCE='||NVL(TO_CHAR(session_rec.fixed_table_sequence),'Null')||crlf;
msg := msg||'V$SESSION.ROW_WAIT_OBJ#=' ||NVL(TO_CHAR(session_rec.row_wait_obj#) ,'Null')||crlf;
msg := msg||'V$SESSION.ROW_WAIT_FILE#=' ||NVL(TO_CHAR(session_rec.row_wait_file#) ,'Null')||crlf;
msg := msg||'V$SESSION.ROW_WAIT_BLOCK#='||NVL(TO_CHAR(session_rec.row_wait_block#),'Null')||crlf;
msg := msg||'V$SESSION.ROW_WAIT_ROW#=' ||NVL(TO_CHAR(session_rec.row_wait_row#) ,'Null')||crlf;
msg := msg||'V$SESSION.LOGON_TIME=' ||NVL(TO_CHAR(session_rec.logon_time,'DD-Mon-YYYY HH24:MI:SS'),'Null')||crlf;
msg := msg||'V$SESSION.LAST_CALL_ET=' ||NVL(TO_CHAR(session_rec.last_call_et) ,'Null')||crlf;
msg := msg||'V$SESSION.PDML_ENABLED=' ||NVL(session_rec.pdml_enabled ,'Null')||crlf;
msg := msg||'V$SESSION.FAILOVER_TYPE=' ||NVL(session_rec.failover_type ,'Null')||crlf;
msg := msg||'V$SESSION.FAILOVER_METHOD='||NVL(session_rec.failover_method,'Null')||crlf;
msg := msg||'V$SESSION.FAILED_OVER=' ||NVL(session_rec.failed_over ,'Null')||crlf;
msg := msg||'V$SESSION.RESOURCE_CONSUMER_GROUP='||NVL(session_rec.resource_consumer_group,'Null')||crlf;
msg := msg||'V$SESSION.PDML_STATUS=' ||NVL(session_rec.pdml_status ,'Null')||crlf;
msg := msg||'V$SESSION.PDDL_STATUS=' ||NVL(session_rec.pddl_status ,'Null')||crlf;
msg := msg||'V$SESSION.PQ_STATUS=' ||NVL(session_rec.pq_status ,'Null')||crlf;
IF auditing THEN
msg := msg||'DBA_AUDIT_TRAIL.OS_USERNAME=' ||NVL(audit_rec.os_username,'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.USERNAME=' ||NVL(audit_rec.username ,'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.USERHOST=' ||NVL(audit_rec.userhost ,'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.TERMINAL=' ||NVL(audit_rec.terminal ,'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.TIMESTAMP=' ||TO_CHAR(audit_rec.timestamp,'DD-Mon-YYYY HH24:MI:SS')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.OWNER=' ||NVL(audit_rec.owner ,'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.OBJ_NAME=' ||NVL(audit_rec.obj_name ,'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.ACTION=' ||audit_rec.action ||crlf;
msg := msg||'DBA_AUDIT_TRAIL.ACTION_NAME=' ||NVL(audit_rec.action_name ,'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.NEW_OWNER=' ||NVL(audit_rec.new_owner ,'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.NEW_NAME=' ||NVL(audit_rec.new_name ,'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.OBJ_PRIVILEGE='||NVL(audit_rec.obj_privilege ,'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.SYS_PRIVILEGE='||NVL(audit_rec.sys_privilege ,'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.ADMIN_OPTION=' ||NVL(audit_rec.admin_option ,'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.GRANTEE=' ||NVL(audit_rec.grantee ,'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.AUDIT_OPTION=' ||NVL(audit_rec.audit_option ,'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.SES_ACTIONS=' ||NVL(audit_rec.ses_actions ,'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.LOGOFF_TIME=' ||NVL(TO_CHAR(audit_rec.logoff_time) ,'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.LOGOFF_LREAD=' ||NVL(TO_CHAR(audit_rec.logoff_lread) ,'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.LOGOFF_PREAD=' ||NVL(TO_CHAR(audit_rec.logoff_pread) ,'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.LOGOFF_LWRITE='||NVL(TO_CHAR(audit_rec.logoff_lwrite),'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.LOGOFF_DLOCK=' ||NVL(audit_rec.logoff_dlock ,'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.COMMENT_TEXT=' ||NVL(audit_rec.comment_text ,'Null')||crlf;
msg := msg||'DBA_AUDIT_TRAIL.SESSIONID=' ||audit_rec.sessionid ||crlf;
msg := msg||'DBA_AUDIT_TRAIL.ENTRYID=' ||audit_rec.entryid ||crlf;
msg := msg||'DBA_AUDIT_TRAIL.STATEMENTID=' ||audit_rec.statementid ||crlf;
msg := msg||'DBA_AUDIT_TRAIL.RETURNCODE=' ||audit_rec.returncode ||crlf;
msg := msg||'DBA_AUDIT_TRAIL.PRIV_USED=' ||NVL(audit_rec.priv_used,'Null')||crlf;
END IF;
msg := msg||'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-'||crlf||crlf;
-- write the message to the error log file
log_file_handle := UTL_FILE.FOPEN (log_file_dir, log_file_name, 'A',maxlinesize);
UTL_FILE.PUT_LINE(log_file_handle,msg);
UTL_FILE.FCLOSE(log_file_handle);
-- send the message by Email
mail_conn := UTL_SMTP.open_connection(smtp_relay, mail_port);
UTL_SMTP.HELO(mail_conn, smtp_relay);
UTL_SMTP.MAIL(mail_conn, sender_address);
UTL_SMTP.RCPT(mail_conn, recipient_address);
UTL_SMTP.DATA(mail_conn, msg);
UTL_SMTP.QUIT(mail_conn);
END IF; -- client_program = MyProgram.exe
END IF;
END;
/ -
Sending a mail from oracle database
Hi,
I have a requirement to send a mail from oracle database.I use UTL_TCP package for this.Although my procedure is executed successfully,i dont get the mails in my inbox.Please help me to figure out a solution.
Thanks in advance....Hi, you must use UTL_SMTP package for send emails, it has more performance and features for debug. You must look the next code, this is a example for send emails.
DECLARE
c UTL_SMTP.CONNECTION;
PROCEDURE send_header(name IN VARCHAR2, header IN VARCHAR2) AS
BEGIN
UTL_SMTP.WRITE_DATA(c, name || ': ' || header || UTL_TCP.CRLF);
END;
BEGIN
c := UTL_SMTP.OPEN_CONNECTION('smtp-server.acme.com');
UTL_SMTP.HELO(c, 'foo.com');
UTL_SMTP.MAIL(c, '[email protected]');
UTL_SMTP.RCPT(c, '[email protected]');
UTL_SMTP.OPEN_DATA(c);
send_header('From', '"Sender" <[email protected]>');
send_header('To', '"Recipient" <[email protected]>');
send_header('Subject', 'Hello');
UTL_SMTP.WRITE_DATA(c, UTL_TCP.CRLF || 'Hello, world!');
UTL_SMTP.CLOSE_DATA(c);
UTL_SMTP.QUIT(c);
EXCEPTION
WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
BEGIN
UTL_SMTP.QUIT(c);
EXCEPTION
WHEN UTL_SMTP.TRANSIENT_ERROR OR UTL_SMTP.PERMANENT_ERROR THEN
NULL; -- When the SMTP server is down or unavailable, we don't have
-- a connection to the server. The QUIT call will raise an
-- exception that we can ignore.
END;
raise_application_error(-20000,
'Failed to send mail due to the following error: ' || sqlerrm);
END;
Also review the next link for get more information about the UTL_SMTP packege.
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_smtp.htm#sthref15587
Regards. -
How to send a mail automatically based on a date from ORACLE database
Hi,
I want to send a mail automatically based on a date from ORACLE database.
Please help me.
thanks
--Saraprograms are available on net to send mail directly from oracle ie procedure s in oracle sending mails
-
Hi All,
I have a database job to send e-mail.That's great!
We have one too!
But no further questions/problems?
Edited by: hoek on Mar 24, 2009 5:51 PM -
Does Adobe Send allow you to select how many days your files can be downloaded - as with Adobe Send Now? Also, why don't I see the virus scanning message any longer with "Send" versus "Send Now"?
We relied upon the "days available for download" to get people to take
action more quickly. The "virus scanning" progress bar was simply another
way of knowing this activity was actually taking place - unless this is
written somewhere in the Adobe Send User Guide.....wherever that is.
On Tue, Dec 2, 2014 at 12:09 PM, bob.treitman <[email protected]> -
Why does my iPhone send me to a select payment type page when I try to download a FREE app from the apps store?
You can only redownload using the Apple store id you purchased the items under
-
Need to send a mail when job window time is over
Hi ,
select * from v$version;
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
========
I have created a job using dbms_scheduler.create_job with a 1 hour window ( created using dbms_scheduler.create_window ) .
My job triggers a stored procedure . Now I have a send_mail code at the end of the stored procedure which sends a mail with plsql log as an attachment . When my job runs more than 1 hour the stored proc is getting stopped and not triggering the mail though I put the same code in exception block ( exception when others ) .
CREATE OR REPLACE PROCEDURE my_sp
AS
BEGIN
-- some code ---
begin
-- send mail --
end
EXCEPTION
WHEN OTHERS
THEN
send mail ( Can I get this piece when window time is over )
END;
Is there any other way I can run the last piece of the proc (send_mail) .
Thanks ,
MaheshMahesh wrote:
Folllowing below note .
http://download.oracle.com/docs/cd/E14072_01/server.112/e10595/scheduse008.htm
but need to attach a file .
SQL> desc utl_mail
PROCEDURE SEND
Argument Name Type In/Out Default?
SENDER VARCHAR2 IN
RECIPIENTS VARCHAR2 IN
CC VARCHAR2 IN DEFAULT
BCC VARCHAR2 IN DEFAULT
SUBJECT VARCHAR2 IN DEFAULT
MESSAGE VARCHAR2 IN DEFAULT
MIME_TYPE VARCHAR2 IN DEFAULT
PRIORITY BINARY_INTEGER IN DEFAULT
REPLYTO VARCHAR2 IN DEFAULT
PROCEDURE SEND_ATTACH_RAW
Argument Name Type In/Out Default?
SENDER VARCHAR2 IN
RECIPIENTS VARCHAR2 IN
CC VARCHAR2 IN DEFAULT
BCC VARCHAR2 IN DEFAULT
SUBJECT VARCHAR2 IN DEFAULT
MESSAGE VARCHAR2 IN DEFAULT
MIME_TYPE VARCHAR2 IN DEFAULT
PRIORITY BINARY_INTEGER IN DEFAULT
ATTACHMENT RAW IN
ATT_INLINE BOOLEAN IN DEFAULT
ATT_MIME_TYPE VARCHAR2 IN DEFAULT
ATT_FILENAME VARCHAR2 IN DEFAULT
REPLYTO VARCHAR2 IN DEFAULT
PROCEDURE SEND_ATTACH_VARCHAR2
Argument Name Type In/Out Default?
SENDER VARCHAR2 IN
RECIPIENTS VARCHAR2 IN
CC VARCHAR2 IN DEFAULT
BCC VARCHAR2 IN DEFAULT
SUBJECT VARCHAR2 IN DEFAULT
MESSAGE VARCHAR2 IN DEFAULT
MIME_TYPE VARCHAR2 IN DEFAULT
PRIORITY BINARY_INTEGER IN DEFAULT
ATTACHMENT VARCHAR2 IN
ATT_INLINE BOOLEAN IN DEFAULT
ATT_MIME_TYPE VARCHAR2 IN DEFAULT
ATT_FILENAME VARCHAR2 IN DEFAULT
REPLYTO VARCHAR2 IN DEFAULT -
Please help, how to send mails faster / send more mails per hour
hello,
in my application i am using mail sender class i have created to send mail to the users to participate in a survey. following is the code for it. i would like to know if there is anything wrong in it coz it takes to much time to send the mails it is taking 2 minustes to send 6 mails i.e 360 mails per hour only.
following is how i instantiate the mail sender class and then generate a http link string dynamically as it is different for all the user.
//////////class where mail sender is instantiated////////////////////
try
setConnection();
st=con.createStatement();
rs=st.executeQuery("select * from "+CNAME+"_campaign");
String SurveyT = new String();
while(rs.next())
SurveyT = rs.getString(2);
rs.close();
rs=st.executeQuery("select * from "+CNAME+"_user");
ss = new MailSender();
while(rs.next())
String userid = rs.getString("userid");
String password = rs.getString("password");
StringBuffer message = new StringBuffer(BodyText.getText().trim());
if(SurveyT.equals("invitational") || SurveyT.equals("single"))
message.append( "\n" + "http://"+IPadd.getText().trim()+"/"+CNAME+"/servlet/login?username="+userid+"&passw="+password);
ss.send(FromField.getText().trim(),userid,SmtpServerID.getText().trim(),MailSub.getText().trim(),message.toString());
else if(SurveyT.equals("general"))
message.append( "\n" + "http://"+IPadd.getText().trim()+"/"+CNAME+"/Index.html");
ss.send(FromField.getText().trim(),userid,SmtpServerID.getText().trim(),MailSub.getText().trim(),message.toString());
st.close();
this.dispose();
catch(SQLException sqlex)
JOptionPane.showMessageDialog(null,sqlex.getMessage());
//Mail Sender class/////////////////
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
import javax.swing.*;
public class MailSender
String sentAddr,fromAddr,smtpServer,body,subject;
public MailSender()
//function send to send the mail
public void send(String from,String to,String smtps,String subj,String messagetext)
fromAddr=new String(from);
sentAddr=new String(to);
smtpServer=new String(smtps);
body=new String(messagetext);
subject=new String(subj);
try
Properties props = System.getProperties();
props.put("mail.smtp.host",smtpServer);
Session session = Session.getDefaultInstance(props,null);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(fromAddr));
msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(sentAddr,false));
msg.setSubject(subject);
msg.setText(body);
msg.setHeader("Survey","MailCheck");
msg.setSentDate(new Date());
Transport.send(msg);
catch(MessagingException mex)
JOptionPane.showMessageDialog(null,mex.getMessage());
}Lots of variables here....Also my maths says only 180 per hour.... i.e. three a minute.
1) you are using a database to get info from. What is the average response time of the DB server? Looks like you are doing one SQL then reading the result table but does the initial SQL take a while?
2) how much data are you passing on to the SMTP server and how fast/slow is the link to that SMTP server? Work out the absolute max amount of data you can transfer over the link then get your average message size and work out a VERY theoretical Max number of messages a minute. Note that real life might approach 80% of this taking TCP/IP and SMTP overheads into account.
3) What sort of load is the SMTP server under? If it's busy you will be only getting a fraction of whatever bandwidth is available. Depending on its design it may be trying to deliver the first message you sent it while you are still pumping more messages down to it. SMTP servers may limit the number of connections per minute from another machine in order to defeat a denial of service attack. Your code makes a connection per email so this may have relevence here.
4) Raw horsepower always helps. When I write stuff to do things like this there is no nice GUI screen etc. Just basic Java that if it has to will write a log if something goes wrong. Maybe just maybe a counter on STD out to show it is still actually doing something. Keep the number of classes used down to the bare minimum. In the old days we used to spend days paring code to the bone - a skill somewhat lost these days.
Hope this gives you some help in finding the bottleneck.
Cheers,
SH -
Problem with the ALV after sending the mail
Good Morning Experts
I have a small issue with the ALV. I have a program, which has to sent email. In My program initially I am displaying basic list in the alv and user can navigate to secondary list also, by clicking on a contract number in the basic list.
I gave a tool button in the tool bar to the user in the basic list, to send the mail. When the user clicks on the I have to send the mail both the lists, basic list and seconday list in the mail as separate attachments.
Mail is going fine and later if the user chooses to see any contract in detail(Secondary List), that time ALV giving dump with message type X. And it is stopping some where in the ALV code
call method cl_gui_cfw=>get_subscriber_by_id
exporting shellid = p_handle-shellid
exceptions others = 1.
if sy-subrc = 0.
</B>message X007 with p_handle-clsid.<B>
endif.
If anybody having an Idea, how to resolve it, please tell me.
Thanks in Advance
PraveenPlease find the code for user_command form and sending the mail. Please look into this advice me if anything wrongly I coded.
*& Form user_command
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
IF r_ucomm EQ '&IC1' OR r_ucomm EQ 'SHOW'.
REFRESH: it_all[],
it_fcat1[],
it_sort[].
LOOP AT it_final INTO wa_final WHERE select EQ 'X' OR xblnr EQ rs_selfield-value.
LOOP AT it_bsid INTO wa_bsid WHERE xblnr EQ wa_final-xblnr AND zuonr IS INITIAL.
wa_all = wa_bsid.
wa_all = wa_bsid.
wa_all-booked = wa_bsid-dmbtr.
IF wa_bsid-augdt IS NOT INITIAL AND wa_bsid-augbl IS NOT INITIAL.
wa_all-paid = wa_bsid-dmbtr.
ENDIF.
wa_all-amtr = wa_all-booked - wa_all-paid.
APPEND wa_all TO it_all.
CLEAR: wa_all,
wa_bsid.
ENDLOOP.
LOOP AT it_bsad INTO wa_bsad WHERE xblnr EQ wa_final-xblnr AND zuonr IS INITIAL.
wa_all = wa_bsad.
wa_all-booked = wa_bsad-dmbtr.
IF wa_bsad-augdt IS NOT INITIAL AND wa_bsad-augbl IS NOT INITIAL.
wa_all-paid = wa_bsad-dmbtr.
ENDIF.
wa_all-amtr = wa_all-booked - wa_all-paid.
APPEND wa_all TO it_all.
CLEAR: wa_all,
wa_bsad.
ENDLOOP.
ENDLOOP.
SORT it_all BY xblnr.
PERFORM fill_fcat2.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_top_of_page = 'TOP_OF_PAGE'
i_grid_title = 'Report to display selected contracts'
is_layout = wa_layout1
it_fieldcat = it_fcat1[]
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_SORT = it_sort[]
i_default = 'X'
i_save = 'A'
is_variant = wa_variant
TABLES
t_outtab = it_all[]
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
CASE r_ucomm.
WHEN 'BACK1' OR 'EXT1'.
PERFORM exit IN PROGRAM saplslvc_fullscreen.
WHEN '&F12' or 'CANCEL'.
PERFORM exit IN PROGRAM saplslvc_fullscreen.
WHEN 'MAIL'.
PERFORM prepare_mail.
ENDCASE.
ENDFORM. "user_command
*& Form prepare_mail
text
--> p1 text
<-- p2 text
FORM prepare_mail .
DATA:
l_lay TYPE pri_params-paart,
l_line TYPE pri_params-linct,
l_cols TYPE pri_params-linsz,
l_val TYPE c,
i_spno TYPE tsp01-rqident,
i_lines TYPE i,
i_bin TYPE i,
i_pack_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
i_recivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
i_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_docdata LIKE sodocchgi1,
i_excel LIKE solisti1 OCCURS 0 WITH HEADER LINE.
i_pos type i.
TYPES:
t_pripar TYPE pri_params,
t_arcpar TYPE arc_params.
"Work areas
DATA:
lw_pripar TYPE t_pripar,
lw_arcpar TYPE t_arcpar,
w_no_of_bytes TYPE i.
l_lay = 'X_65_255'.
l_line = 65.
l_cols = 255.
"Read, determine, change spool print parameters and archive parameters
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
in_archive_parameters = lw_arcpar
in_parameters = lw_pripar
layout = l_lay
line_count = l_line
line_size = l_cols
no_dialog = 'X'
IMPORTING
out_archive_parameters = lw_arcpar
out_parameters = lw_pripar
valid = l_val
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
OTHERS = 4.
*l_val eq space
IF sy-subrc = 0.
lw_pripar-prrel = space.
lw_pripar-primm = space.
NEW-PAGE PRINT ON
NEW-SECTION
PARAMETERS lw_pripar
ARCHIVE PARAMETERS lw_arcpar
NO DIALOG.
ENDIF.
DATA: ls_prnt TYPE slis_print_alv.
ls_prnt-print = ''.
ls_prnt-prnt_title = 'X'.
ls_prnt-no_coverpage = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_top_of_page = 'TOP_OF_PAGE'
i_grid_title = 'Report to display collection pattern on Clearing Date'
is_layout = wa_layout
it_fieldcat = it_fcat[]
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'PF_STATUS_SET'
IT_SORT = it_sort[]
i_default = 'X'
i_save = 'A'
is_variant = wa_variant
TABLES
t_outtab = it_final[]
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WRITE 'Test program to generate and download as PDF'.
NEW-PAGE PRINT OFF.
CALL FUNCTION 'ABAP4_COMMIT_WORK'.
i_spno = sy-spono.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = i_spno
no_dialog = 'X'
IMPORTING
pdf_bytecount = w_no_of_bytes
pdf_spoolid = w_pdf_spoolid
btc_jobname = w_jobname
btc_jobcount = w_jobcount
TABLES
pdf = it_pdf.
LOOP AT it_pdf INTO wa_pdf.
IF w_pos = 34170.
PERFORM attach.
ENDIF.
w_stuff+w_pos(134) = wa_pdf.
ADD 134 TO w_pos.
ENDLOOP.
IF NOT ( w_stuff IS INITIAL ).
PERFORM attach.
ENDIF.
CLEAR wa_pdf.
PERFORM fill_receivers TABLES i_recivers.
PERFORM fill_contents TABLES i_contents.
DESCRIBE TABLE i_contents LINES i_lines.
READ TABLE i_contents INDEX i_lines.
CLEAR i_pack_list-transf_bin.
i_pack_list-head_start = 1.
i_pack_list-head_num = 1.
i_pack_list-body_start = 2.
i_pack_list-body_num = i_lines.
i_pack_list-doc_type = 'RAW'.
APPEND i_pack_list.
CLEAR i_pack_list.
*u2022 Attachment (pdf-Attachment)
CONCATENATE p_date6(2) p_date4(2) p_date+0(4) INTO w_date1 SEPARATED BY '.'.
DESCRIBE TABLE it_att LINES i_lines.
READ TABLE it_att INTO wa_att INDEX i_lines.
i_pack_list-transf_bin = 'X'.
i_pack_list-head_start = '1'.
i_pack_list-head_num = '0'.
i_pack_list-body_start = '1'.
i_pack_list-body_num = i_lines.
i_pack_list-doc_type = 'PDF'.
i_pack_list-obj_name = 'Renewal List'.
CONCATENATE 'Report to display outstanding premium' 'Executed on' w_date1 INTO i_pack_list-obj_descr SEPARATED BY space.
i_pack_list-obj_descr = 'Exchange Rates uploaded to the database'.
i_pack_list-obj_langu = 'E'.
i_pack_list-doc_size = i_lines * 255.
APPEND i_pack_list.
CLEAR i_pack_list.
REFRESH: it_pdf[].
CLEAR wa_pdf.
REFRESH: it_all[],
it_fcat1[],
it_sort[].
LOOP AT it_final INTO wa_final.
LOOP AT it_bsid INTO wa_bsid WHERE xblnr EQ wa_final-xblnr AND zuonr IS INITIAL.
wa_all = wa_bsid.
wa_all-booked = wa_bsid-dmbtr.
IF wa_bsid-augdt IS NOT INITIAL AND wa_bsid-augbl IS NOT INITIAL.
wa_all-paid = wa_bsid-dmbtr.
ENDIF.
wa_all-amtr = wa_all-booked - wa_all-paid.
APPEND wa_all TO it_all.
CLEAR: wa_all,
wa_bsid.
ENDLOOP.
LOOP AT it_bsad INTO wa_bsad WHERE xblnr EQ wa_final-xblnr AND zuonr IS INITIAL.
wa_all = wa_bsad.
wa_all-booked = wa_bsad-dmbtr.
IF wa_bsad-augdt IS NOT INITIAL AND wa_bsad-augbl IS NOT INITIAL.
wa_all-paid = wa_bsad-dmbtr.
ENDIF.
wa_all-amtr = wa_all-booked - wa_all-paid.
APPEND wa_all TO it_all.
CLEAR: wa_all,
wa_bsad.
ENDLOOP.
ENDLOOP.
NEW-PAGE PRINT ON
NEW-SECTION
PARAMETERS lw_pripar
ARCHIVE PARAMETERS lw_arcpar
NO DIALOG.
ENDIF.
SORT it_all BY xblnr.
PERFORM fill_fcat2.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_top_of_page = 'TOP_OF_PAGE'
i_grid_title = 'Report to display selected contracts'
is_layout = wa_layout1
it_fieldcat = it_fcat1[]
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
it_sort = it_sort[]
i_default = 'X'
i_save = 'A'
is_variant = wa_variant
TABLES
t_outtab = it_all[]
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
NEW-PAGE PRINT OFF.
CALL FUNCTION 'ABAP4_COMMIT_WORK'.
i_spno = sy-spono.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = i_spno
no_dialog = 'X'
IMPORTING
pdf_bytecount = w_no_of_bytes
pdf_spoolid = w_pdf_spoolid
btc_jobname = w_jobname
btc_jobcount = w_jobcount
TABLES
pdf = it_pdf.
LOOP AT it_pdf INTO wa_pdf.
IF w_pos = 34170.
PERFORM attach1.
ENDIF.
w_stuff+w_pos(134) = wa_pdf.
ADD 134 TO w_pos.
ENDLOOP.
IF NOT ( w_stuff IS INITIAL ).
PERFORM attach1.
ENDIF.
CLEAR wa_pdf.
DESCRIBE TABLE it_att LINES i_lines.
ADD 1 TO i_lines.
DESCRIBE TABLE it_att1 LINES i_bin.
READ TABLE it_att1 INTO wa_att INDEX i_bin.
DESCRIBE TABLE it_att LINES i_lines.
READ TABLE it_att INTO wa_att INDEX i_lines.
i_pack_list-transf_bin = 'X'.
i_pack_list-head_start = '1'.
i_pack_list-head_num = '0'.
i_pack_list-body_start = i_lines.
i_pack_list-body_num = i_bin.
i_pack_list-doc_type = 'PDF'.
i_pack_list-obj_name = 'Renewal List-Details'.
CONCATENATE 'Outstanding Premium-Details' w_date1 INTO i_pack_list-obj_descr SEPARATED BY space.
i_pack_list-obj_descr = 'Exchange Rates uploaded to the database'.
i_pack_list-obj_langu = 'E'.
i_pack_list-doc_size = i_bin * 255.
APPEND i_pack_list.
CLEAR i_pack_list.
APPEND LINES OF it_att1 to it_att.
i_docdata-obj_name = 'Renewal List'.
CONCATENATE 'Oustanding Premium' 'as on' w_date1 INTO i_docdata-obj_descr SEPARATED BY space.
CONDENSE i_docdata-obj_descr.
i_docdata-obj_langu = 'E'.
i_docdata-obj_prio = '1'.
i_docdata-no_change = 'X'.
i_docdata-sensitivty = 'F'.
i_docdata-doc_size = ( i_lines - 1 ) * 255 + STRLEN( wa_att ).
***Data for Header
i_header-line = 'Header'. APPEND i_header.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = i_docdata
commit_work = 'X'
TABLES
packing_list = i_pack_list[]
object_header = i_header
contents_bin = it_att[]
contents_txt = i_contents[]
receivers = i_recivers[]
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.
ELSE.
MESSAGE 'Document Sent' TYPE 'S'.
ENDIF.
ENDFORM. " prepare_mail
Thanks
Praveen -
Sending e-mail prior to Ora 8.0 from PL/SQL
Dear peers,
I would like to e-mail from a Pl/SQL block but can't use utl_smtp because the Oracle version is prior to 8.0. Could you recommend ways of doing so?
My OS is Unix and have Perl,and PHP as well. I have little experience with any of this tools, so please be simple.
Any suggestions would be greatly appreciated.
Thanks, CIPHi,
The following article on sending mail is for Oracle 7.x as well and is specific to UNIX. It uses DBMS_PIPE PL/SQL package, a PRO*C program and UNIX sendmail utility for sending e-mail. For this, the database you are using should have DBMS_PIPE package installed.
Hope that helps,
Srinivas
ARTICLE : How to Generate E-mail within PL/SQL Routines?
References
For DBMS_PIPE/architecture, refer to the following:
"Oracle7 Server Application Developer's Guide" (A32536-1)
"Oracle8 Application Developer's Guide Release 8.0" (A58241-01)
"Oracle8i Supplied PL/SQL Packages Reference Release 2 (8.1.6)" (A76936-01)
Preparation
Perform the steps below to setup the necessary files.
Note: When testing on your machine, the code generates simple
e-mail messages for demonstration purposes.
1. Read the main comment block of maildaemon.pc and make appropriate
changes.
2. Read the main comment block of maildaemon.sql and make appropriate
changes.
3. Connect to SQL*Plus. If not already setup, GRANT EXECUTE ON DBMS_PIPE TO
where userid is public or the schema owner of the package.
4. Run maildaemon.sql to setup dependencies.
5. Copy proc.mk (demo_proc.mk on v8 databases) into directory and issue
the following make line to build the executable for maildaemon:
make -f proc.mk build EXE=maildaemon OBJS=maildaemon.o
PROCFLAGS="sqlcheck=semantics parse=full userid=scott/tiger"
Note: Replace userid=scott/tiger with the schema to build under.
6. Run the maildaemon executable.
7. To test, modify the code below and run from SQL*Plus:
declare
dummy number;
begin
maildaemon.setauditon;
dummy:= maildaemon.email_msg1( '[email protected]' );
dummy:= maildaemon.email_msg2( '[email protected]', 'scott',
to_char( sysdate, 'dd-Mon-yyyy hh:mi:ss' ));
maildaemon.setauditoff;
maildaemon.stop;
end;
maildaemon.sql
rem file: maildaemon.sql
rem last modified: 10/15/98
rem
rem This source file generates dependencies for the maildaemon executable
rem such as logging as well as the PL/SQL package interface to communicate
rem with the maildaemon Pro*C application.
rem
rem Please note: this is just a sample. You will need to modify/replace the
rem email_msg1() and email_msg2() functions in the maildaemon package.
rem Both functions have been provided as simple demonstrations on how to
rem write an interface. Consult the Application Developers Guide for more
rem information on using the DBMS_PIPE package.
rem table: emailaudit
rem purpose: contain auditing messages from the maildaemon Pro*C application
create table emailaudit
msgid number constraint msgid_pk primary key,
msgtype varchar2( 20 ),
msgstat varchar2( 100 )
rem sequence: emailmsgseq
rem purpose: to allow maildaemon Pro*C application to generate unique message
rem identifiers for opening temporary files and auditing.
create sequence emailmsgseq;
rem package: maildaemon
rem purpose: provide a PL/SQL interface to generate e-mail messages
create or replace package maildaemon as
/* setauditon( )
* procedure
* parameters: timeout: timeout factor for informing the maildaemon exe
* exceptions: -20030: error sending message to maildaemon exe
* description: turn on auditing in the maildaemon exe
procedure setauditon( timeout number default 10 );
/* setauditoff( )
* procedure
* parameters: timeout: timeout factor for informing the maildaemon exe
* exceptions: -20030: error sending message to maildaemon exe
* description: turn off auditing in the maildaemon exe
procedure setauditoff( timeout number default 10 );
/* stop( )
* procedure
* parameters: timeout: timeout factor for informing the maildaemon exe
* exceptions: -20030: error sending message to maildaemon exe
* description: shutdown the maildaemon exe
procedure stop( timeout number default 10 );
/* email_msg1( )
* function
* parameters: emailaddr: email address to send email to
* timeout: timeout factor for informing the maildaemon exe
* returns: return code from mail daemon call
* exceptions: -20010: maildaemon had an error during sending email
* -20011: error during sending message to maildaemon exe
* -20012: message returned from maildaemon other than done
* -20013: maildaemon returned an error code other than 0
* description: generic sample to demonstrate a simple interface to the
* maildaemon exe
function email_msg1( emailaddr in varchar2, timeout number default 10 ) return number;
/* email_msg2( )
* function
* parameters: emailaddr: email address to send email to
* userid: userid to place in the mail text
* timestamp: timestamp to place in the mail text
* timeout: timeout factor for informing the maildaemon exe
* returns: return code from mail daemon call
* exceptions: -20010: maildaemon had an error during sending email
* -20011: error during sending message to maildaemon exe
* -20012: message returned from maildaemon other than done
* -20013: maildaemon returned an error code other than 0
* description: generic sample to demonstrate a simple interface to the
* maildaemon exe by passing parameters
function email_msg2( emailaddr in varchar2, userid in varchar2, timestamp in varchar2,
timeout number default 10 ) return number;
end maildaemon;
create or replace package body maildaemon as
procedure setauditon( timeout number default 10 ) is
retval number;
begin
dbms_pipe.pack_message( 'AUDIT' );
retval := dbms_pipe.send_message( 'maildaemon', timeout );
if retval <> 0 then
raise_application_error( -20030,
'maildaemon: error sending audit command. Status = ' | | retval );
end if;
end setauditon;
procedure setauditoff( timeout number default 10 ) is
retval number;
begin
dbms_pipe.pack_message( 'NOAUDIT' );
retval := dbms_pipe.send_message( 'maildaemon', timeout );
if retval <> 0 then
raise_application_error( -20030,
'maildaemon: error sending noaudit command. Status = ' | | retval );
end if;
end setauditoff;
procedure stop( timeout number default 10 ) is
retval number;
begin
dbms_pipe.pack_message( 'STOP' );
retval := dbms_pipe.send_message( 'maildaemon', timeout );
if retval <> 0 then
raise_application_error( -20030,
'maildaemon: error sending stop command. Status = ' | | retval );
end if;
end stop;
function email_msg1( emailaddr in varchar2, timeout number default 10 ) return number is
retval number;
result varchar2(20);
cmdcode number;
pipenm varchar2(30);
begin
pipenm := dbms_pipe.unique_session_name;
dbms_pipe.pack_message( 'MSG1' );
dbms_pipe.pack_message( pipenm );
dbms_pipe.pack_message( emailaddr );
retval := dbms_pipe.send_message( 'maildaemon', timeout );
if retval <> 0 then
raise_application_error( -20010,
'maildaemon: error while sending email. Status = ' | | retval );
end if;
retval := dbms_pipe.receive_message( pipenm, timeout );
if retval <> 0 then
raise_application_error( -20011,
'maildaemon: error while receiving daemon response. Status = ' | | retval );
end if;
dbms_pipe.unpack_message( result );
if result <> 'done' then
raise_application_error( -20012,
'maildaemon: error code returned from daemon other than done' );
end if;
dbms_pipe.unpack_message( cmdcode );
if cmdcode <> 0 then
raise_application_error( -20013,
'maildaemon: error code returned from daemon ' | | cmdcode );
end if;
return cmdcode;
end email_msg1;
function email_msg2( emailaddr in varchar2, userid in varchar2, timestamp in varchar2,
timeout number default 10 ) return number is
retval number;
result varchar2(20);
cmdcode number;
pipenm varchar2(30);
begin
pipenm := dbms_pipe.unique_session_name;
dbms_pipe.pack_message( 'MSG2' );
dbms_pipe.pack_message( pipenm );
dbms_pipe.pack_message( em ailaddr );
dbms_pipe.pack_message( userid );
dbms_pipe.pack_message( timestamp );
retval := dbms_pipe.send_message( 'maildaemon', timeout );
if retval <> 0 then
raise_application_error( -20010,
'maildaemon: error while sending email. Status = ' | | retval );
end if;
retval := dbms_pipe.receive_message( pipenm, timeout );
if retval <> 0 then
raise_application_error( -20011,
'maildaemon: error while receiving daemon response. Status = ' | | retval );
end if;
dbms_pipe.unpack_message( result );
if result <> 'done' then
raise_application_error( -20012,
'maildaemon: error code returned from daemon other than done' );
end if;
dbms_pipe.unpack_message( cmdcode );
if cmdcode <> 0 then
raise_application_error( -20013,
'maildaemon: error code returned from daemon ' | | cmdcode );
end if;
return cmdcode;
end email_msg2;
end maildaemon;
maildaemon.pc
* file: maildaemon.pc
* last modified: 10/15/98
* This source code is written for the UNIX environment to allow PL/SQL
* to generate e-mail. Please note, the following code might not work on
* your system due to configurations of the operating system or your
* environment. Please consult your systems administrator for more
* information on specifics.
* Variables to be set prior to building:
* mailhost: the mail application to generate email queuing. Default is
* "/usr/lib/sendmail".
* mailswitch: the mail application switches to pass to $mailhost. Default
* is "-t".
* userpass: the username/password to connect to the database. Default is
* "scott/tiger"
* logfile: the logfile to write system messages to.
* Functions to be modified:
* main( ): will need to modify the message handling portion to handle the
* messages from the maildaemon package (PL/SQL). The changes that need
* to be made are in the else if( ... ) portion with handling MSG1 and
* MSG2.
* msg1( ): this is just a stub sample. Replace this with appropriate code
* and change the call in main( ).
* msg2( ): this is just a stub sample. Replace this with appropriate code
* and change the call in main( ).
* System include files
#include <stdio.h>
#include <string.h>
EXEC SQL INCLUDE sqlca;
* Global variable declaration
EXEC SQL BEGIN DECLARE SECTION;
char *mailhost = "/usr/lib/sendmail";
/* the mail host application to gen email requests */
char *mailswitch = "-t";
/* switches to pass to $mailhost */
char *userpass = "scott/tiger";
/* userid/password to connect to the database as */
char *logfile = "maildaemon.log";
/* log file to write messages to */
FILE *loghnd = NULL;
/* file pointer to log file */
int retval;
/* return value for DBMS_PIPE send */
int calval;
/* return value set from DBMS_PIPE receive */
varchar pipeid[ 30 ];
/* return pipe identifier */
char filename[ 128 ];
/* filename to use for email */
varchar command[ 20 ];
/* system command received from DBMS_PIPE receive */
char syscommand[ 2000 ];
/* hold system command for generating email request */
varchar emailaddr[ 256 ];
/* hold the email address for sending message to */
int auditing= 0;
/* set whether auditing is to be done */
varchar string1[ 256 ];
/* hold string 1 passed from server */
varchar string2[ 256 ];
/* hold string 2 passed from server */
EXEC SQL END DECLARE SECTION;
* Function definition
* conerr( )
* handle connection error
void conerr( )
char msgbuf[ 512 ]; /* message buffer */
int msglen; /* message buffer space used */
int maxmsglen; /* maximum message length */
EXEC SQL WHENEVER SQLERROR CONTINUE;
sqlglm( msgbuf, &maxmsglen, &msglen );
fprintf( loghnd, "maildaemon: error during connect to database\n" );
fprintf( loghnd, "error reported: %.*s\n", msglen, msgbuf );
fprintf( loghnd, "maildaemon: aborting...\n" );
exit( 1 );
} /* end conerr( ) */
* sqlerr( )
* handle general SQL error
* does not cause maildaemon to abort
void sqlerr( )
char msgbuf[ 512 ]; /* message buffer */
int msglen; /* message buffer space used */
int maxmsglen; /* maximum message length */
EXEC SQL WHENEVER SQLERROR CONTINUE;
sqlglm( msgbuf, &maxmsglen, &msglen );
fprintf( loghnd, "maildaemon: error during processing\n" );
fprintf( loghnd, "error reported: %.*s\n", msglen, msgbuf );
fprintf( loghnd, "maildaemon: continuing...\n" );
} /* end sqlerr( ) */
* msg1( )
* stub function example 1 for sending an email.
int msg1( )
EXEC SQL BEGIN DECLARE SECTION;
int retcode = 0; /* return code */
long msgid; /* unique message id */
FILE msghnd = NULL; / file handle to write email file */
EXEC SQL END DECLARE SECTION;
if( emailaddr.len == 0 )
{ /* null address passed */
fprintf( loghnd, "maildaemon: null address specified to msg1( )\n" );
retcode= 999;
return( retcode );
} /* end if */
/* get the next sequence number for uniqueness */
EXEC SQL WHENEVER SQLERROR GOTO sqlerror1;
EXEC SQL SELECT emailmsgseq.nextval INTO :msgid FROM dual;
/* generate the filename so it is unique and open the file */
sprintf( filename, "emailmsg.txt.%ld", msgid );
msghnd= fopen( filename, "w" );
if( msghnd == NULL )
{ /* there was an error opening the output file */
retcode= 1;
if( auditing )
{ /* set audit trail */
EXEC SQL INSERT INTO emailaudit VALUES( :msgid, 'msg1', 'maildaemon: status code of: ' | | :retcode );
EXEC SQL COMMIT;
} /* end if */
return( retcode );
} /* end if */
/* generate email */
fprintf( msghnd, "To: %s\n", emailaddr.arr );
fprintf( msghnd, "Subject: msg1 message type\n\n" );
fprintf( msghnd, "\tmsg1 message type was called for emailing\n" );
fprintf( msghnd, "\ngenerated by maildaemon\n" );
/* close the file */
fclose( msghnd );
/* create the command line and send the message */
sprintf( syscommand, "%s %s < %s", mailhost, mailswitch, filename );
retcode= system( syscommand );
/* remove the temporary file */
unlink( filename );
if( auditing )
{ /* set audit trail */
EXEC SQL INSERT INTO emailaudit VALUES( :msgid, 'msg1', 'maildaemon: status code of: ' | | :retcode );
EXEC SQL COMMIT;
} /* end if */
EXEC SQL WHENEVER SQLERROR CONTINUE;
return( retcode );
sqlerror1:
retcode= 1;
sqlerr( );
return( retcode );
} /* end msg1( ) */
* msg2( )
* stub function example 2 for sending an email.
int msg2( )
EXEC SQL BEGIN DECLARE SECTION;
int retcode = 0; /* return code */
long msgid; /* unique message id */
FILE msghnd = NULL; / file handle to write email file */
EXEC SQL END DECLARE SECTION;
if( emailaddr.len == 0 )
{ /* null address passed */
fprintf( loghnd, "maildaemon: null address specified to msg2( )\n" );
retcode= 999;
return( retcode );
} /* end if */
/* get the next sequence number for uniqueness */
EXEC SQL WHENEVER SQLERROR GOTO sqlerror2;
EXEC SQL SELECT emailmsgseq.nextval INTO :msgid FROM dual;
/* generate the filename so it is unique and open the file */
sprintf( filename, "emailmsg.txt.%ld", msgid );
msghnd= fopen( filename, "w" );
if( msghnd == NULL )
{ /* there was an error opening the output file */
retcode= 1;
if( auditing )
{ /* set audit trail */
EXEC SQL INSERT INTO emailaudit VALUES( :msgid, 'msg2', 'maild aemon: status code of: ' | | :retcode );
EXEC SQL COMMIT;
} /* end if */
return( retcode );
} /* end if */
/* generate email */
fprintf( msghnd, "To: %s\n", emailaddr.arr );
fprintf( msghnd, "Subject: msg2 message type\n\n" );
fprintf( msghnd, "\tmsg2 message type was called for emailing\n" );
fprintf( msghnd, "Userid of user: %s\n", string1.arr );
fprintf( msghnd, "Timestamp of transaction: %s\n", string2.arr );
fprintf( msghnd, "\ngenerated by maildaemon\n" );
/* close the file */
fclose( msghnd );
/* create the command line and send the message */
sprintf( syscommand, "%s %s < %s", mailhost, mailswitch, filename );
retcode= system( syscommand );
/* remove the temporary file */
unlink( filename );
if( auditing )
{ /* set audit trail */
EXEC SQL INSERT INTO emailaudit VALUES( :msgid, 'msg2', 'maildaemon: status code of: ' | | :retcode );
EXEC SQL COMMIT;
} /* end if */
EXEC SQL WHENEVER SQLERROR CONTINUE;
return( retcode );
sqlerror2:
retcode= 1;
sqlerr( );
return( retcode );
} /* end msg2( ) */
void main( )
/* open file and verify logging */
loghnd = fopen( logfile, "a" );
if( loghnd == NULL )
{ /* the logfile was unable to be opened */
printf( "maildaemon: error opening logfile (%s)\n", logfile );
exit( 1 );
} /* end if */
/* connect to the database */
EXEC SQL WHENEVER SQLERROR DO conerr( );
EXEC SQL CONNECT :userpass;
fprintf( loghnd, "maildaemon: connected.\n" );
/* loop until stop command given */
EXEC SQL WHENEVER SQLERROR DO sqlerr();
while( 1 == 1 )
{ /* inifinite loop */
/* reset values */
emailaddr.len = 0;
string1.len= 0;
string2.len = 0;
/* get type of message from 'server' */
EXEC SQL EXECUTE
begin
:calval := dbms_pipe.receive_message( 'maildaemon' );
if :calval = 0 then
dbms_pipe.unpack_message( :command );
end if;
end;
END-EXEC;
if( calval == 0 )
{ /* message received. determine the command */
command.arr[ command.len ]= '\0';
if( !strcmp(( char * ) command.arr, "STOP" ))
{ /* 'server' specified to stop */
fprintf( loghnd, "maildaemon: shutdown in progress...\n" );
break;
} /* end if */
else if( !strcmp(( char * ) command.arr, "AUDIT" ))
{ /* set auditing on */
fprintf( loghnd, "maildaemon: enable auditing...\n" );
auditing= 1;
} /* end else if */
else if( !strcmp(( char * ) command.arr, "NOAUDIT" ))
{ /* set auditing off */
fprintf( loghnd, "maildaemon: disable auditing...\n" );
auditing= 0;
} /* end else if */
else if( !strcmp(( char * ) command.arr, "MSG1" ))
{ /* call for message 1 */
/* retrieve the message */
EXEC SQL EXECUTE
begin
dbms_pipe.unpack_message( :pipeid );
dbms_pipe.unpack_message( :emailaddr );
end;
END-EXEC;
/* copy into host variable */
emailaddr.arr[ emailaddr.len ]= '\0';
/* generate the email */
retval= msg1( );
/* reply with response */
EXEC SQL EXECUTE
begin
dbms_pipe.pack_message( 'done' );
dbms_pipe.pack_message( :retval );
:retval := dbms_pipe.send_message( :pipeid );
end;
END-EXEC;
} /* end else if */
else if( !strcmp(( char * ) command.arr, "MSG2" ))
{ /* call for message 2 */
/* retrieve the message */
EXEC SQL EXECUTE
begin
dbms_pipe.unpack_message( :pipeid );
dbms_pipe.unpack_message( :emailaddr );
dbms_pipe.unpack_message( :string1 );
dbms_pipe.unpack_message( :string2 );
end;
END-EXEC;
/* copy into host variable */
emailaddr.arr[ emailaddr.len ]= '\0';
string1.arr[ string1.len ]= '\0';
string2.arr[ string2.len ]= '\0';
/* generate the email */
retval= msg2( );
/* reply with response */
EXEC SQL EXECUTE
begin
dbms_pipe.pack_message( 'done' );
dbms_pipe.pack_message( :retval );
:retval := dbms_pipe.send_message( :pipeid );
end;
END-EXEC;
} /* end else if */
else
{ /* invalid command received */
fprintf( loghnd, "maildaemon: illegal command... ignoring request.\n" );
} /* end else */
} /* end if */
else
{ /* time out error occured */
fprintf( loghnd, "maildaemon: timeout or other error while waiting for signal request.\n" );
} /* end else */
} /* end while */
/* clean up and exit */
EXEC SQL COMMIT WORK RELEASE;
fprintf( loghnd, "maildaemon: shutdown.\n" );
fclose( loghnd );
} /* end main( ) */
null -
Problem sending a mail to many adresses with attachments (Javamail, JSP)
Hi,
i got a problem with JavaMail trying to send a mail to different email-adresses in a JSP. The mail should be send to about 27 adresses, which works fine whenever i send it without any attachments. As soon as i attach a file, the mail still gets send without an error, but only to about 12 adresses instead of the intended 27. I get the adresses out of a database and in either case, there ist the correct amount of adresses. The Mailserver doesnt report anything - it sends the mails without any problem at the 12 adresses.
Here is the part of the code, thats sending:
Properties props = new Properties();
props.put("mail.smtp.host", "192.168.1.1 ");
Session s;
MimeMessage message;
InternetAddress from = new InternetAddress("[email protected]");
InternetAddress to;
s = Session.getInstance(props,null);
Transport trans=s.getTransport("smtp");
//get adresses from db
while (rspartner.next())
to = new InternetAddress(rspartner.getString("postfach"));
message.addRecipient(Message.RecipientType.TO, to);
empfaengerzeile=rspartner.getRow();
//out.println(empfaengerzeile+" --- "+rspartner.getString("postfach")+"<br>");
BodyPart messageBodyPart=new MimeBodyPart();
messageBodyPart.setText(nachricht);
Multipart multipart=new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
//Dateinamen und Speicherort des Plan ermitteln
queryAnhang=dbCon.prepareStatement("select pfad from m_baukoord_kommentar where baukoord_id=? and titel='Entwurfsplan'");
queryAnhang.setString(1,request.getParameter("projektid"));
rsanhang=queryAnhang.executeQuery();
rsanhang.next();
datei=rsanhang.getString("pfad");
//Datei zippen
quellpfad+= ebaukonr.trim() + "/" + datei;
if(datei.contains("."))
zipfilename=datei.substring(0,datei.lastIndexOf('.'))+".zip";
else
zipfilename=datei+".zip";
zielpfad=config.getServletContext().getRealPath("")+"/strasse/UserDownloads/" + zipfilename;
ZipOutputStream zipout = new ZipOutputStream(new FileOutputStream(zielpfad));
zipout.setLevel(9);
zipout.setMethod(ZipOutputStream.DEFLATED);
FileInputStream in = new FileInputStream(quellpfad);
zipout.putNextEntry(new ZipEntry(datei));
int len;
while ((len = in.read(buf)) > 0) {
zipout.write(buf, 0, len);
zipout.closeEntry();
in.close();
zipout.close();
//Datei anhaengen
messageBodyPart = new MimeBodyPart();
FileDataSource source = new FileDataSource(zielpfad);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName("Entwurfsplan.zip");
multipart.addBodyPart(messageBodyPart);
message.setSubject("Neues Projekt " + titel + " verfügbar");
message.setContent(multipart);
trans.send(message);With active debug i got following information:
The first mail in the debug-log is with the source code as quoted in my first post, the second mail is when i cut out the part which generates and adds the attachement. I had to make the adresses anonymous, but the second mail contains a lot more adresses then the first, although they both use the same query with same parameters, etc.
Have i done something wrong with the attachements? Overwriting headers, syntax errors, anything? I'm out of ideas...
edit: Had to cut out the debug-log because it is too big. It just said that everything was working ok, but the first mail contains too few adresses and the second (without attachement) the correct number of adresses. I can mail the log, if you like.
Maybe you are looking for
-
I'm setting up my iphone 5 and it wont communicate with my computer. What's going on?
Help!
-
Combo box select default value.
Hi, I am using Combo box to display the status of the document. my code is oForm = SBO_Application.Forms.Item("I8_BGU_") Dim oCombo1 As SAPbouiCOM.ComboBox oForm.DataSources.UserDataSources.Add("ComboSr
-
So I changed my password & when I changed It I kind of had put thought that same instant to put my old password back because I didn't want to forget. when I did put the same new password on the pass code it didn't work. I have tried 8 attempts with t
-
Error with Microsoft.ApplicationServer.Caching.VelocityPacketTooBigException
Hello All I am getting the below error while I am searching for a huge record (more than 8.5 MB). Microsoft.ApplicationServer.Caching.VelocityPacketTooBigException: Size of message to be sent is 8837220 bytes which is larger than the maximum message
-
Hi all. I just took over someone else's work that uses OSB. She did all the installation and some initial services. My current project requires that I set up a DB adapter, so for the first time, I tried using JDeveloper and Oepe version of eclipse. T