Send an email base on data in database
Hi,
I have created an stored procedure,which will send an email on certain condition but it doesn't seen to work.
can anyone pls help.
sp :=
CREATE OR REPLACE procedure AMC.amc_renewal(amc_date date)
as
begin
for dates in (select serial_no,
ORION_SUPPLIER_CODE,
VENDOR,
AMC_COST,
START_DATE,
LAST_DATE,
EMAIL,
MAIL_DATE
from AMC_DETAIL
where TO_DATE(MAIL_DATE,'DD-MM-YYYY') = TO_DATE(SYSDATE,'DD-MM-YYYY')) loop
APEX_mail.send(p_to => DATES.EMAIL,
p_from => '[email protected]',
p_subj => 'You have an appt on '||DATES.START_DATE,
p_body => 'Dear '||DATES.SERIAL_NO ||
'you have an appt on '||DATES.LAST_DATE);
wwv_flow_mail.push_queue(
P_SMTP_HOSTNAME => '10.X.X.X',
P_SMTP_PORTNO => 'XX'
end loop;
end;
/
Shirish wrote:
Hi,
I have created an stored procedure,which will send an email on certain condition but it doesn't seen to work.When you have a problem always include the following information with your question:
<li>Full APEX version
<li>Full DB/version/edition/host OS
<li>Web server architecture (EPG, OHS or APEX listener/host OS)
<li>Browser(s) and version(s) used
Define "doesn't seen to work". As well as saying what doesn't happen, tell us what does:
<li>Error messages
<li>Mail queues/logs
<li>Debug traces
Always post code wrapped in <tt>\...\</tt> tags.
CREATE OR REPLACE procedure AMC.amc_renewal(amc_date date)
as
begin
for dates in (select serial_no,
ORION_SUPPLIER_CODE,
VENDOR,
AMC_COST,
START_DATE,
LAST_DATE,
EMAIL,
MAIL_DATE
from AMC_DETAIL
where TO_DATE(MAIL_DATE,'DD-MM-YYYY') = TO_DATE(SYSDATE,'DD-MM-YYYY')) loopWhat is the data type of the <tt>MAIL_DATE</tt> column? If it's DATE it doesn't need <tt>TO_DATE</tt>. <tt>SYSDATE</tt> is definitely a date and doesn't need <tt>TO_DATE</tt>.
Do not perform unnecessary type conversions. It's confusing and inefficient. What you probably mean here is:
where mail_date >= trunc(sysdate) and mail_date < trunc(sysdate) + 1 /* assuming mail_date contains time information */or
where mail_date = trunc(sysdate) /* if the time component of all mail_date values is 00:00:00 */
APEX_mail.send(p_to => DATES.EMAIL,
p_from => '[email protected]',
p_subj => 'You have an appt on '||DATES.START_DATE,
p_body => 'Dear '||DATES.SERIAL_NO ||
'you have an appt on '||DATES.LAST_DATE);
wwv_flow_mail.push_queue(
P_SMTP_HOSTNAME => '10.X.X.X',
P_SMTP_PORTNO => 'XX'
);Pushing the mail queue after every send is inefficient and difficult to manage. The best approach is not to include this in application code and let the scheduled background job handle it.
end loop;
end;
Similar Messages
-
Send confirmation email with form data
Hi:
I need to have a form do several things when the user hits submit and I'm hoping someone can give me some insite:
1. It needs to insert record into my DB (got that one figured out)
2. It then needs to send two emails with all of the form information, the first one to the email address that the user inputs in a field, the second to a general box (ie [email protected]). This is where I am seriously stuck.
Any help you can offer would be much appreciated!
thx!I'm using the Dreamweaver Insert Record (it's a MySQL db with PHPmyAdmin as the face). This seems like it should be a fairly common and standard request and I just can't seem to find the right answer. I can post code, if that would help.
ab -
How to send out email from table data every day?
want to implement email function:
send out data in email from a table with select everyday
how to implement it in ASE 12.5?You can use the Job Scheduler functionality within ASE or a UNIX OS cron job to cause something to happen at a particular time every day.
With Job Scheduler, you might have it use xp_cmdshell to execute a script on the OS,
while cron would just execute the script directly.
The script would log into ASE, run the select and store the results into a file, then send the file contents.
A simple example of such a script file might be:
isql -Usa -Ppassword -o /work/my_output.txt << EOF
select * from mydb..mystatus
go
EOF
mailx -s"My Daily Status" bret < /work/my_output.txt
As the file contains your password, be sure permissions are set so only you can read and execute the file. -
Sender's email id in function module SO_DOCUMENT_SEND_API1
Hi All,
I am fetching the sender's email id dynamically from HR database and then trying to use it while sending email via FM SO_DOCUMENT_SEND_API1. But the email does not go. The FM is erroring out with return code 6.
If I maintain email id in the user profile (Tcode SU01) and then simply pass sy-uname instead of complete email address in parameter - sender_address then it is working fine.
Is it not possible to explicitly send 'From email id' or 'Sender-address' parameter when sending mails using FM SO_DOCUMENT_SEND_API1 like for example [email protected]
The experts please solve my problem...
Thanks & regards,
RashmiIn this object i was able to send the mail. just check the type of reciever.
DATA: objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 0 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
objhex like SOLIX occurs 0 with header line,
reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE.
DATA: doc_chng LIKE sodocchgi1,
v_tab_lines1 LIKE sy-tabix ,
v_temp type sy-tabix , "
v_doc_hdr type sy-tabix ,
v_tab_lines LIKE sy-tabix .
DATA : v_up TYPE i,
v_nup TYPE i.
IF cb_nonup EQ c_x.
READ TABLE i_get_latest WITH KEY upstream = space.
IF sy-subrc EQ 0.
v_nup = 1.
ENDIF.
ENDIF.
IF cb_upstm EQ c_x.
READ TABLE i_get_latest WITH KEY upstream = c_x.
IF sy-subrc EQ 0.
v_up = 1.
ENDIF.
ENDIF.
Setting up File Name & Mail Subject
doc_chng-obj_name = 'Attachment'(067). " File Name
IF v_up EQ 1 AND
v_nup EQ 1.
Subject
doc_chng-obj_descr = 'The list of Upstream / Non-Upstream'(066).
objtxt = 'Upstream/Non-Upstream files are attached'(065). " Body
ELSEIF v_up EQ 1.
Subject
doc_chng-obj_descr = 'The list of Upstream'(064).
objtxt = 'Upstream file is attached'(063). " Body
ELSEIF v_nup EQ 1.
Subject
doc_chng-obj_descr = 'The list of Non-Upstream'(062).
objtxt = 'Non-Upstream file is attached'(061). " Body
ENDIF.
data : v_del type x value '0A',
v_tab type x value 9 . "
Appending the body of the Mail
concatenate objtxt v_del into objtxt.
APPEND objtxt.
DESCRIBE TABLE objtxt LINES v_doc_hdr.
READ TABLE objtxt INDEX v_doc_hdr.
doc_chng-doc_size = ( v_tab_lines - 1 ) * 480 + STRLEN( objtxt ).
doc_chng-doc_size = ( v_doc_hdr - 1 ) * 255 + STRLEN( objtxt ).
Creation of the entry for the Mail Contents
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = v_doc_hdr.
objpack-doc_type = 'RAW'.
APPEND objpack.
v_temp = 1. "
if cb_nonup eq c_x.
Creation of the Non-Upstream Xcel document as attachment
CLEAR objbin.
LOOP AT i_get_latest WHERE upstream EQ space.
objbin = i_get_latest .
concatenate objbin v_del into objbin.
APPEND objbin.
objtxt = i_get_latest.
concatenate objtxt v_del v_del into objtxt.
concatenate i_get_latest-massn+0(6)
v_tab
i_get_latest-massg+0(30)
v_tab
i_get_latest-aedtm
v_tab
i_get_latest-begda
v_tab
i_get_latest-pernr
v_tab
i_get_latest-nachn+0(12)
v_tab
i_get_latest-vorna+0(12)
v_tab
i_get_latest-midnm
v_tab
i_get_latest-ptext+0(20)
v_tab
i_get_latest-orgeh+0(8)
v_tab
i_get_latest-orgtx+0(25)
v_tab
i_get_latest-name1+0(30)
into objtxt.
append objtxt.
clear objtxt.
concatenate i_get_latest-bukrs+0(4)
v_tab
i_get_latest-kostl+0(10)
v_tab
i_get_latest-ltext+0(25)
v_tab
i_get_latest-ort01+0(15)
v_tab
i_get_latest-state+0(10)
v_tab
i_get_latest-func_org
v_tab
i_get_latest-fun_dept
v_tab
i_get_latest-chief_name
v_tab
i_get_latest-ess_role
v_tab
i_get_latest-email_id
into objtxt.
shift objtxt by 2 places right.
append objtxt.
Appending an empty line to demarcate records in attachment file
clear objtxt.
append objtxt.
ENDLOOP.
Creation of the entry for the Non-Upstream attachment
objhead = 'Non-Upstream.xls'(060). " Attachment Name
APPEND objhead.
clear objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 2.
objpack-body_num = v_tab_lines - v_doc_hdr.
objpack-doc_type = 'XLS'. "
objpack-doc_type = 'TXT'. "
objpack-obj_name = 'Non Upstream'(059).
objpack-obj_descr = 'Non Upstream'(059).
objpack-doc_size = v_tab_lines * 480. "
objpack-doc_size = ( v_tab_lines - v_doc_hdr ) * 255. "
APPEND objpack.
endif.
if cb_upstm eq c_x.
Creation of the Upstream Xcel document as attachment
CLEAR objbin.
LOOP AT i_get_latest WHERE upstream EQ c_x.
objbin = i_get_latest .
concatenate objbin v_del into objbin.
APPEND objbin .
objtxt = i_get_latest.
concatenate objtxt v_del v_del into objtxt.
append objtxt.
concatenate i_get_latest-massn+0(6)
v_tab
i_get_latest-massg+0(30)
v_tab
i_get_latest-aedtm
v_tab
i_get_latest-begda
v_tab
i_get_latest-pernr
v_tab
i_get_latest-nachn+0(12)
v_tab
i_get_latest-vorna+0(12)
v_tab
i_get_latest-midnm
v_tab
i_get_latest-ptext+0(20)
v_tab
i_get_latest-orgeh+0(8)
v_tab
i_get_latest-orgtx+0(25)
v_tab
i_get_latest-name1+0(30)
into objtxt.
append objtxt.
clear objtxt.
concatenate i_get_latest-bukrs+0(4)
v_tab
i_get_latest-kostl+0(10)
v_tab
i_get_latest-ltext+0(25)
v_tab
i_get_latest-ort01+0(15)
v_tab
i_get_latest-state+0(10)
v_tab
i_get_latest-func_org
v_tab
i_get_latest-fun_dept
v_tab
i_get_latest-chief_name
v_tab
i_get_latest-ess_role
v_tab
i_get_latest-email_id
into objtxt.
shift objtxt by 2 places right.
append objtxt.
Appending an empty line to demarcate records in attachment file
clear objtxt.
append objtxt.
ENDLOOP.
DESCRIBE TABLE objbin LINES v_tab_lines1. "
DESCRIBE TABLE objtxt LINES v_tab_lines1. "
objhead = 'Upstream.xls'(070). " Attachment Name
APPEND objhead.
if cb_nonup eq c_x.
v_temp = v_tab_lines. "
v_tab_lines = v_tab_lines1 - v_tab_lines.
else.
v_tab_lines = v_tab_lines1.
endif.
Creation of the entry for the compressed attachment
objpack-transf_bin = 'X'. "
clear objpack-transf_bin. "
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1. "
objpack-body_start = v_temp + 1. "
objpack-body_num = v_tab_lines. "
objpack-body_num = v_tab_lines - 1.
objpack-doc_type = 'XLS'. "
objpack-doc_type = 'TXT'. "
objpack-obj_name = 'Upstream'(058).
objpack-obj_descr = 'Upstream'(058).
objpack-doc_size = v_tab_lines * 480. "
objpack-doc_size = ( v_tab_lines ) * 255. "
APPEND objpack.
endif.
Completing the recipient list
reclist-receiver = p_emlid.
reclist-rec_type = 'U'.
APPEND reclist.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
CONTENTS_HEX = objhex
receivers = reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc <> 0.
MESSAGE i000 WITH 'Error in sending Email'(052) .
ELSE.
MESSAGE i000 WITH 'Message sent successfully !'(050).
ENDIF.
ENDFORM. " send_email -
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 -
Sending an email from my database
Hi!
I wanna send an email from within a procedure from my database, Im thinking of using the utl_smtp package, I know I need acces from my database server to the smtp server, that can be done... when u use the utl_smtp package u need to specify the smtp host, the email address of the sender, the email address of the receptor, and some other stuff, what I wonder is: Where do u specify the password of the email address of the sender?, I mean, it doesnt make sense that u use an email address to send an email and u dont specify the password of that account
In all the samples Ive seen all over internet I havent found something that tells me something about it...
Any Help???A lot of smtp servers do not require a username/password when sending mail, only when receiving mail.
If you need verification, you can do it with utl_smtp:
utl_smtp.command( conn, 'AUTH LOGIN');
utl_smtp.command( conn, utl_raw.cast_to_varchar2( utl_encode.base64_encode( utl_raw.cast_to_raw( cuser ))) );
utl_smtp.command( conn, utl_raw.cast_to_varchar2( utl_encode.base64_encode( utl_raw.cast_to_raw( cpassword ))) ); -
how do I set an email to send at a specific time/date in the future e.g. tomorrow at 9am. I am on an iMAC using apple's version of windows
apple don't have a version of windows
only microsoft have windows
as how one automatate windows to send mails at a time
googled it for you
http://www.howtogeek.com/125045/how-to-easily-send-emails-from-the-windows-task- scheduler/
more options in the search
https://www.google.dk/search?client=opera&q=automatically+send+email+in+windows& sourceid=opera&ie=UTF-8&oe=UTF-8 -
I restored my phone data onto my new phone. When I tried to send email it asked me for my email password, which I couldn't remember. Now I keep getting an error message whenever I try to send an email. How do I reset this so it works?
Until you can enter that password it kept asking for, you won't be able to send mail. You need to go to Settings>Mail, Contacts, Calendars>Email Account you are referring to>SMTP server, and make changes there. If you cannot remember your email password, you will have to get in touch with your provider to be able to change it.
-
How to send an email from the database
i have create a post insert trigger at the database level for the emp table and that trigger call a procedure and that procedure send a email to the new employee, i the trigger send the firt name , second name , last name and the email address to the procedure .so my questions is about the command that will send the email to the new employee ,and the send email will look like this
Dear "fist name "second name" "last name"
welocme to..........................................................This thread could help answer some of your questions:
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:2391265038428
C. -
Exporting activity data as a PDF / sending as email from within package
Hello,
We are currently developing an E-learning package which involves the learners building up a check list on an "ipad" as they go through the course, which we would like them to then be able to save at the end of the course so they can review it later.
We've managed to implement a print function, however we really need them to be able to save this data in some way. Does any one know how we could push this data back to the LMS so it can somehow be downloaded and saved (in a good, branded format) or even better how we could make it into a PDF so it can be saved from with in the SCORM package or even in some way emailed.
Any help would be much appreciated.
Samhi
The funnier part is that
u can actually type in the sender's email id irrespective of the mail host used
Like @hotmail.com,@yahoo.com etc.
The receiver will get the mails from the email id that u wrote .
The problem u r facing is becoz of the incorrect mail host server ip address
Try to get in touch with the network admin for the mail server ip address
other way is
get the name it would be like
smtp.domain name .
hope that helps -
How to color data in EXCEL while sending to email?
Dear Friends,
I have a doubt.
I have a internal table IT_MARA.
I sent this data via EMAIL to the user by using the Function Module -'SO_NEW_DOCUMENT_ATT_SEND_API1' as EXCEL fortmat.
My question is How to color this data in EXCEL while i am sending to email?
Regards
MoosaHi,
Try these link
http://www.saptechies.com/how-to-send-some-abap-data-to-an-excel-sheet-using-ole-automation/
http://www.sap-img.com/abap/download-to-excel-with-format-border-color-cell-etc.htm
Regards,
Manish -
Setting maximum packet size in JDBC driver to send data to database
Could someone tell me how I can set the JDBC connection property of maximum packet size to send data to database?
Regards
RashedHi thanks....I'm having this strange SQLException while trying to insert BLOB image data to Oracle database. I'm saying this strange because for the same image that has been inserted before it's throwing the exception. My program is run from Oracle form and then some image data are inserted into database through a loop. I can't realize what's the problem inside my code that's causing this problem. In fact, when I run my program independently not from Oracle Form, it runs fine, every image data get inserted into database. Given below is my code snippet:
public void insertAccDocs(String[] accessions) throws SQLException
for(int q=0; q<accessions.length; q++)
final String docName = accessions[q];
dbThread = new Thread(new Runnable(){
public void run()
try{
System.out.println("insertDB before connection");
getConnected();
System.out.println("insertDB after connection");
st=con.createStatement();
//String docName = acc; commented
// String docName = singleAccession;
String text = formatFree;
String qry = "INSERT INTO DOCUMENT VALUES
('"+docName+"','"+text+"','"+formatted+"','"+uiid+"')";
System.out.println("parentqry"+qry);
int ok=0;
ok=st.executeUpdate(qry);
if(ok==1)
System.out.println("INSERTION SUCCESS= "+ok);
System.out.println("Image List Size"+ imgList.size());
// inserting into child
for(int i=0;i<imgList.size(); i++)
String imgPath = ""+imgList.get(i);
System.out.println("db"+imgPath);
FileInputStream fin = new FileInputStream(imgPath);
BufferedInputStream bufStr = new BufferedInputStream(fin);
byte[] imgByte = new byte[bufStr.available()];
String img = "" + imgNameList.get(i);
System.out.println("imgid="+i);
callable = con.prepareCall("{call prc_insert_docimage(?,?,?)}");
callable.setString(1,docName);
callable.setString(2,img);
callable.setBinaryStream(3, bufStr , (int)imgByte.length);
callable.execute();
callable.close();
con.commit();
con.close();
else
System.out.println("INSERTION NOT SUCCESS");
// } //else end of severalAcc
}catch(Exception err){ //try
System.out.println(err.toString());
} //run
}); //runnable
dbThread.start();
}And the exception thrown is :
java.sql.SQLException: Data size bigger than max size for this type: #####
Please let me know if possible how I can get around this.
Regards
Rashed -
WHEN I SEND AN EMAIL WITH A MICROSOFT WORD OR PDF ATTACHMENT TO MY APPLE COMPUTERS OR I PAD IT SHOWS UP AS WIN MAIL.DAT AND I CANNOT OPEN THE FILE, THIS JUST STARTED HAPPENING. PLEASE HELP ME FIND AN ANSWER. JIM
Please do not type in all caps, that is considered shouting and we can hear you just fine.
This is a MS Office issue, I'd suggest taking it up with Microsoft or a MS Office forum. -
Send email including the data field into the html message body
Hi all,
I would like to send an email to each recipient once only, and including a data field into the html body message. I am not sure how to achive that with my current stored procedure.
USE [CallManager]
GO
/****** Object: StoredProcedure [dbo].[PersonalCallsReminder] Script Date: 08/27/2014 10:26:55 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[PersonalCallsReminder]
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Email Users
declare @email varchar(max)
declare mycursor cursor FAST_FORWARD for
SELECT dbo.HumersStaffExtension.email
FROM dbo.Calls_Mobile_Header INNER JOIN
dbo.HumersStaffExtension ON
dbo.Calls_Mobile_Header.TelNumber = dbo.HumersStaffExtension.telnr_prv COLLATE SQL_Latin1_General_CP1_CI_AS
GROUP BY dbo.Calls_Mobile_Header.RecordStatus, dbo.HumersStaffExtension.usr_id, dbo.HumersStaffExtension.email,
dbo.HumersStaffExtension.res_id
HAVING (dbo.Calls_Mobile_Header.RecordStatus = N'0') AND (NOT (dbo.HumersStaffExtension.email IS NULL))
OPEN mycursor;
FETCH NEXT FROM mycursor
INTO @email
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'CallsManagement',
@recipients = @email ,
@body_format = 'HTML',
@subject = 'Personal Calls Reminder',
@body = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Personal Calls Reminder</title>
<style type="text/css">
body {
font-family: "Times New Roman", Times, serif;
font-size: 11pt;
.auto-style1 {
background-color: #FFFF00;
</style>
</head>
<body>
<div>
<table style="width: 800px">
<tr>
<td>Dear,<br />
<br />
Please review your phone bills and submit your personal calls using the following link:<br />
<a href="http://companyxyz/personalcalls/">Personal Calls</a></td>
</tr>
</table>
<br/>
<table style="width: 800px">
<tr>
<td><strong>Kindly be informed that the deadline to process new bills is on the
<span class="auto-style1">15th of each month</span>.</strong></td>
</tr>
</table>
<br/>
<table style="width: 800px">
<tr>
<td>For assistance, please contact <a href="mailto:[email protected]">[email protected]</a></td>
</tr>
</table>
<br/>
<table style="width: 800px">
<tr>
<td><strong>*** This is an automatically generated email, please do not reply ***</strong></td>
</tr>
</table>
</div>
</body>
</html>
FETCH NEXT FROM mycursor
INTO @email
END
CLOSE mycursor;
DEALLOCATE mycursor;
END
Changing the query to the following:
SELECT TOP (100) PERCENT dbo.HumersStaffExtension.email, dbo.Calls_Mobile_Header.ExtractDate
FROM dbo.Calls_Mobile_Header INNER JOIN
dbo.HumersStaffExtension ON
dbo.Calls_Mobile_Header.TelNumber = dbo.HumersStaffExtension.telnr_prv COLLATE SQL_Latin1_General_CP1_CI_AS
GROUP BY dbo.Calls_Mobile_Header.RecordStatus, dbo.HumersStaffExtension.usr_id, dbo.HumersStaffExtension.email, dbo.HumersStaffExtension.res_id,
dbo.Calls_Mobile_Header.ExtractDate
HAVING (dbo.Calls_Mobile_Header.RecordStatus = N'0') AND (NOT (dbo.HumersStaffExtension.email IS NULL))
ORDER BY dbo.HumersStaffExtension.email
Will provide me with the following results:
email ExtractDate
[email protected]
July-2014
[email protected]
August-2014
[email protected]
July-2014
[email protected]
August-2014
Is it possible to send email to [email protected] once only including in the html message body the ExtractDate field results for July-2014 and August-2014?
I appreciate any assist on the issue.
Thank you in advance.Refer the below code highlighted in bold.
USE [CallManager]
GO
/****** Object: StoredProcedure [dbo].[PersonalCallsReminder] Script Date: 08/27/2014 10:26:55 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[PersonalCallsReminder]
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Email Users
declare @email varchar(max),@date datetime
declare @temp table (email varchar(50), extractDate datetime)
insert into @temp
SELECT TOP (100) PERCENT dbo.HumersStaffExtension.email, dbo.Calls_Mobile_Header.ExtractDate
FROM dbo.Calls_Mobile_Header INNER JOIN
dbo.HumersStaffExtension ON
dbo.Calls_Mobile_Header.TelNumber = dbo.HumersStaffExtension.telnr_prv COLLATE SQL_Latin1_General_CP1_CI_AS
GROUP BY dbo.Calls_Mobile_Header.RecordStatus, dbo.HumersStaffExtension.usr_id, dbo.HumersStaffExtension.email, dbo.HumersStaffExtension.res_id,
dbo.Calls_Mobile_Header.ExtractDate
HAVING (dbo.Calls_Mobile_Header.RecordStatus = N'0') AND (NOT (dbo.HumersStaffExtension.email IS NULL))
ORDER BY dbo.HumersStaffExtension.email
declare mycursor cursor FAST_FORWARD for SELECT DISTINCT email from @temp
OPEN mycursor;
FETCH NEXT FROM mycursor
INTO @email
WHILE @@FETCH_STATUS = 0
BEGIN
DECLARE @date nvarchar(200)
SELECT @date=Stuff((SELECT ',' + [extractDate]
FROM @temp where email = @email
FOR xml path('')), 1, 1, '')
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'CallsManagement',
@recipients = @email ,
@body_format = 'HTML',
@subject = 'Personal Calls Reminder',
@body = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Personal Calls Reminder</title>
<style type="text/css">
body {
font-family: "Times New Roman", Times, serif;
font-size: 11pt;
.auto-style1 {
background-color: #FFFF00;
</style>
</head>
<body>
<div>Extract Date : ' + @date + '</div>
<div>
<table style="width: 800px">
<tr>
<td>Dear,<br />
<br />
Please review your phone bills and submit your personal calls using the following link:<br />
<a href="Personal">http://companyxyz/personalcalls/">Personal Calls</a></td>
</tr>
</table>
<br/>
<table style="width: 800px">
<tr>
<td><strong>Kindly be informed that the deadline to process new bills is on the
<span class="auto-style1">15th of each month</span>.</strong></td>
</tr>
</table>
<br/>
<table style="width: 800px">
<tr>
<td>For assistance, please contact <a href="[email protected]:[email protected]">[email protected]</a></td>
</tr>
</table>
<br/>
<table style="width: 800px">
<tr>
<td><strong>*** This is an automatically generated email, please do not reply ***</strong></td>
</tr>
</table>
</div>
</body>
</html>
FETCH NEXT FROM mycursor
INTO @email
END
CLOSE mycursor;
DEALLOCATE mycursor;
END
Regards, RSingh -
How to install database notification send to email.
Hi,
Anyboddy help for how to install notification send to email.
AquilGul wrote:
hi
how to install database 10g and forms & reports developer 10g on windows xp 32 bit? and which one is to install first? how to connect them together? where can i find complete guideThis link will help you http://tahiti.oracle.com/
Maybe you are looking for
-
New Developement vs. Correction
Hello everybody, I have an question about the organisation of BW-developement. We have D, Q and P system. We have been gone live some times ago with release 1.0 of our BW project. Since this time we are working on the next release 2.0, so we are deve
-
E4200 and USB Drive 2.0 help
Hi I have owned a E4200 since the day it was released. I just now today bought an external drive to connect to it though. I bought a Seagate 1.5T GoFlex Desk which is on the list of compatible drives. My question is. I connected it and it is working,
-
Want to change the default sort order of a Advanced table
Hi all , Hope all of you doing good. I am trying to change the deafult sort order of a " View Applicants" advanced table on Irecruitment selfservice page , using personalization feature but its not sorting as expected. The default sort order is asc b
-
Discoverer 3.1.36.06 bug?
Dicoverer 3.1.36.06 Bug? Hello, I've been having trouble trying to setting privileges to User IDs in Discoverer 3.1.36.06 Administration Edition. This seems to be a very basic problem that I'm sure lots of people have already detected it. The problem
-
Cost assignment in travel expense
if we don't use the FI module, should we activate the cost assignment in travel expense? how to deal with this problem? thx