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

Similar Messages

  • How to add the date field in the dso and info cube

    Hi all.
    I am new to bi 7. in the earlier version v hav to button to add the date field. but in the bi 7 der is no option so can any body tell me how to add the date field in the data targets
    Thanks & Regard
    KK

    my prob is solved
    KK

  • What purpose is the Data field in the registry on an individual file extension exclusion in Endpoint Protection?

    File extension exclusions for System Center Endpoint Protection are at
    HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Microsoft Antimalware\Exclusions\Extensions
    and consist of a REG_DWORD value, named as a file extension such as .mdf, and a corresponding Data element, which always appears to be 0x00000000
    Can this data value ever be anything else, and if so, what are the possible values and their meanings? If not, I'm curious why not just make it a REG_SZ and leave it blank, rather than a data type that requires a value.

    The data field is always 0x00000000. I think other values would be ignored. Only the Name field seems to be important.
    The funny thing is that the exclusion entry can be a REG_SZ and it will work just the same. In fact, if you use the tool that creates a GPO to deploy EP policy instead of using ConfigMgr, the entries are created as REG_SZ instead of DWORD.
    I'm not sure why both methods are used, but the antimalware engine seems to interpret them the same.

  • Still on the inclusion of the time/date field into the spreadsheet file, with 2 real values?

    I have tried to convert the 2 real values to decimal strings, and then taken these 2 values, as well as the date/time strings, put it into an array, converted the array to decimal number, and plugged it into the 1D input of the spreadsheet vi. However, for the date and time, i get the first part only, in a decimal.i.e,for 12:30pm-->12.0000 and for 23/04/2001-->23.0000.
    How can i get the right values, show me an example if u can.
    Thanks.

    1- Open write to spreadsheet file vi.
    2- Save a copy as "Write string array to spreadsheet.vi" or something.
    3- Open this copy.
    4- Replace the numerical controls in the 1D and 2D arrays with string controls.
    5- Save this vi
    6- Now you can wire a string array to this vi and have a spreadsheet from there.
    Remember to modify the COPY, and be careful with the format string.

  • Filling out the date fields in the forms

    Hi,
    I'm trying to fill out a form (http://www.uscis.gov/files/form/i-134.pdf). The regular text fields are working fine, but I've problem with date fields in this document.
    When I set the value of any date field (e.g. see "Date submitted" in the middle-right of last page), Acrobat Reader assigns the same value to all other date fields - which is completely wrong. And if I delete any value it has assigned, it deletes the values of other date fields as well.
    Is it a bug in Reader, or something is wrong with the form? I've the latest Reader 8.1.2 + security patch, running on Windows.
    Regards,
    Michael.

    It is the design of the form. It isn't a bug of Adobe Reader or Adobe Acrobat.

  • My Tcp/ip multi-client server is not passing the data string into the flatten to string vi

    I am using labview Multi-connection cleint and server to build my own multi-client server connection.
      The problem i am having is that the data does not get through the flatten to string vi. Would anyone be kind enough to tell me why is that happening? and what I do to fix it.
      Attached code . My goal is to send data to the client via tcp/ip and use the data to perform certain task.
      Thanks a whole lot
    Attachments:
    multiconnection-server.vi ‏39 KB
    multiconnection-client.vi ‏21 KB

    Instead, I decided to upload the code and recent mods I have made to it .
    see attached
    Attachments:
    multiconnection-clienttest.vi ‏43 KB
    multiconnection-servertest.vi ‏21 KB

  • When entering credit card details, is the date field for the start date or expiry date? [was: payment]

    I had my bank card accidently cancelled by my bank. I have entered the new card number into payment section and it is asking for a date. Is that date the time the card began or finishes - the section does not make is clear. Thanks

    I know of no banking or credit company on the planet that would ever ask or need to ask about the "beginning" date on a crdedit or debit card.
    I'd have no way of replying to such an absurd question if I were ever asked. 

  • Sorting of Date field in the SQL Query useing ORDER BY

    Hi
    I am facing a problem when I am getting the results of a query from the ORacle 8i database using jdbc connection.
    The query is having a date field and I have to sort the query results using ORDER By for the Date field. The query is giving exact results in the SQL PLus interface.
    When I am getting this results in the GUI where servlets are being used an Exception is coming as not supported RefreshRow method.
    If anyone has faced this problem and have got the solutions please let me know.
    thanks
    sulfy

    That doesn't sound at all like an SQL problem.
    More like you trying to do updates on the resultset which is not allowed ...
    send a some code (not to much pls :) and we'll be
    able to help more
    cu
    Spieler

  • Date fields in the Maintainence View.

    Hello friends,
                   I created a maintanence view which of 2 steps. This view contains a DATE field of data element type 'DATS". Now the problem is -"
    1. In the first screen  of the viewI am not able to see only the DATE field(Over view scr).
    2. But I able to see the same field in the 2nd screen(Maintanence Screen).
    Not only to my View I maintained ' Table Maintanence Generator" to some more tables.There also I am not able to see the date field in the first screen, unless it is a key field.
    Thanks in advance.

    Hi
    Step 1: Create & Maintain Table (SE11)
    Screen 101: ABAP Dictionary: Initial Screen
    Screen 102: Maintain Table -> Delivery and Maintenance
    Screen 103: Maintain Table -> Fields
    [] SE11: Enter Table Name -> Create
    Enter Table Description (Mandatory Field)
    Select Delivery Class
    Set maintenance level
    Enter Fields, Assign Data Elements
    Save Entries
    Check Inconsistencies
    Activate Table
    Go To Technical Settings (SCREEN 104)
    Delivery Class: The delivery class controls the transport of table data when
    installing or upgrading, in a client copy and when transporting between customer
    systems. The delivery class is also used in the extended table
    maintenance.
    There are the following delivery classes:
    A: Application table (master and transaction data).
    C: Customer table, data is maintained by the customer only.
    L: Table for storing temporary data.
    G: Customer table. The customer namespace must be defined in table TRESC. (Use
    Report RDDKOR54 here).
    E: System table with its own namespaces for customer entries.
    S: System table, data changes have the same status as program changes.
    W: System table (e.g. table of the development environment) whose
    data is transported with its own transport objects (e.g. R3TR PROG, R3TR TABL,
    etc.).
    Data Browser/Table View Maint.: This indicator specifies
    whether it is possible to display/maintain a table or view using the maintenance
    tools Data Browser (transaction SE16) and table view maintenance (transactions
    SM30 and SM31).
    MANDT field is mandatory for Client dependant tables
    Technical Settings: The technical settings control, for example, table buffering.
    Indexes: To speed up data selection, you can create secondary indexes for the table
    Append Structure: Append structures are used for enhancements that are not included in the standard.
    Screen 104: Maintain Technical Settings
    Select Data Class (Mandatory) [APPL0]
    Select Size Category (Table size - No. of records - Mandatory) [1 to 6]
    Specify Buffering [allowed / not allowed]
    Save
    Check Inconsistencies
    Activate & Go Back to “Maintain Table Screen”
    Data Class: The data class defines the physical area of the database (for ORACLE
    the TABLESPACE) in which your table is logically stored. If you choose a data
    class correctly, your table will automatically be assigned to the correct area
    when it is created on the database.
    The most important data classes
    are (other than the system data):
    APPL0 Master data
    APPL1 Transaction data
    APPL2 Organizational and customizing data
    Size category: The size category determines the probable space requirement for a table in the database.
    Buffering: The buffering status specifies whether or not a table may be buffered.
    Screen 105: Maintain Table
    Screen 106: Maintain Enhancement Category (ECC 6.0 onwards)
    -> Extras -> Enhancement Category
    Select Enhancement Category
    Enhancement Category: Structures and tables that were defined by SAP in the ABAP
    Dictionary can be enhanced subsequently by customers using Customizing includes
    or append structures. The enhancements do not only refer to structures/ tables
    themselves, but also to dependent structures that adopt the enhancement as an
    include or referenced structure. Append structures that only take effect at the
    end of the original structure can also cause shifts - in the case of dependent
    structures - even within these structures.
    Screen 107: Maintain Table -> Table Maintenance Generator
    Screen 108: Generate Table Maintenance Dialog: Generation Environment
    -> Utilities -> Table Maintenance Generator OR [] SE54
    Specify Authorization Group [&NC&]
    Select Maintenance type [One Step/Two Step]
    Mention Screen Numbers [1/2]
    Save & Go Back
    Single step: Only overview screen is created i.e. the Table Maintenance Program will have only one screen where you can add, delete or edit records.Two step: Two screens namely the overview screen and Single screen are created. The user can see the key fields in the first screen and can further go on to edit further details.

  • Problem with displaying Date field in the table.

    Hi All,
    I am trying to display data into a table UI Element. 
    In that data, i have one DATE type field. While displaying data in DATE field, it will display like this "01.02.2009".
    Now my requirement is if i want to modify that DATE field, it will allow to modify "01.02.2009"  to "26.02.2009".
    But while modifying DATE field , I want to show the Calender of that month, in that i  have to select the another date.
    (Like normal Date UI Element will show that calender).
    Can anyone please help me.
    Thanks in Advance!
    Regards,
    Sreelakshmi.

    Hi,
          Go to the context attribute that was mapped to the DATE field of the table and change the perperty INPUT HELP MODE to  AUTOMATIC and it works.
    Regards,
    Manne.

  • Viewing and Removing the Time part of the Date field

    Hi,
    I have Date field in a table.
    but in SQL plus when I do
    select date from table
    this gives me only the Date values and not the timestamps in the date.
    I believe Oracle stores 'Date' and 'Time' in fields with Data Type 'Date'.
    How do I print the timestamps also in the SQL query?
    Moreover, if I have to extract the date field, reset the timestamp to 00:00:00, and store back the date field (with 00 time), how do I do that?
    Thanks in advance
    - Manu

    Hi,
    If you want to retry date and time you can:
    SELECT TO_CHAR(DATE,'YYYY/MM/DD HH24:MI:SS') FROM TABLE;
    If you want truncate time when inserting in a table simply use TRUNC function
    INSERT INTO TABLE (DATE) VALUES (TRUNC(YOUR_DATE));
    To extract and insert with time 00:00:00
    INSERT INTO TABLE1 (SELECT TRUNC(DATE) FROM TABLE2);
    I hope this help you.

  • Using a parmater field for a Date field using the "in the period" selection

    Users would like to fetch records using the "in the period" record selection. They would like to be prompted on the period to run the report. ie
    MonthToDate
    YearToDate
    Last7Days
    Last4WeeksToSun
    LastFullWeek
    LastFullMonth
    AllDatesToToday
    etc...
    I've created a parameter with a dropdown list of values. However the parmeter field I created isn't available as a value in the date field in the "Select Record Expert" function.
    Is there a work around?

    Ron,
    Unfortunately you still have a little bit more work to do... but not much.
    You need to add a formula to your selection criteria. Something along these lines:
    IF {?DateRange} = "MonthToDate" THEN {TableName.DateField} in MonthToDate ELSE
    IF {?DateRange} = "YearToDate" THEN {TableName.DateField} in YearToDate ELSE
    IF {?DateRange} = "Last7Days" THEN {TableName.DateField} in Last7Days ELSE
    IF {?DateRange} = "Last4WeeksToSun" THEN {TableName.DateField} in Last4WeeksToSun ELSE
    IF {?DateRange} = "LastFullWeek" THEN {TableName.DateField} in LastFullWeek ELSE
    IF {?DateRange} = "LastFullMonth" THEN {TableName.DateField} in LastFullMonth ELSE
    IF {?DateRange} = "AllDatesToToday" THEN {TableName.DateField} in AllDatesToToday
    On the plus side, you'll be able to go back into your parameter and add some spaces to list options... which will look better for the end users.
    HTH,
    Jason

  • Strange error in online Adobe form for the date field

    Hi Experts,
    I am facing strange problem with online Adobe forms. I could able to save data when i click save button on the form.
    But some times in the form the date field is throwing error message 'MMDDYYYY field is invalid' when i click on save button.
    Is this the problem with versions of Adobe liveCycle designer, Adobe reader or GUI?
    Thanks in advance,
    Ram

    Hi
    Check the format (in the object pallete) of the date field in Adobe liveCycle Designer, If it is not set already set it according to your requirement. then see if it works
    Hope this helps
    Regards
    Amita

  • How to store forms fields into the session ?

    Hi All,
    I have to store forms fields into the session.
    I have four forms (htm forms) in four jsps and there are total 25 fields.
    I am inserting all the fields into the database at once while user submit the last form.
    I want to use session to store forms fields.
    So please anybody tell me how to do that.
    Is the following code correct to store the forms fields into
    the sesstion........
    // creating a session
    HttpSession session=request.getSession(true);
    // retrieving form fields
    String name=request.getParameter("customer_name");
    String business=request.getParameter("business");
    String address=request.getParameter("address");
    and so on....
    // store form fields into the session
    session.setAttribute("name",name);
    session.setAttribute("business",business);
    session.setAttribute("address",address);
    and so on....
    and later on get the value as:
    session.getAttribute("name");
    session.getAttribute("business");
    session.getAttribute("address");
    and so on....
    OR
    is there another way to store form fields into the session.
    Please guide and reply with coding.....
    Please answer and help.
    Thanks
    Amitindia

    I don't mean to be an *** but I have no desire to help someone so unwilling to think >>and do. Go through some of these tutorial, do the examples in each and you will be far >>better equipped to ask questions:
    http://www.google.co.za/search?hl=en&q=%2Bjsp+%2Bjavabean+%2Btutorial&b >>tnG=Google+Search&meta=
    I was just asking that if I use the following
    <jsp:useBean id="cart" scope="session" class="session.Carts" />
    <jsp:setProperty name="cart" property="address" value="myaddress" />
    </jsp:useBean>then will I be able to acheive my aim as I have to store form fields into the session and later retreive while user submit the last form.
    Please read my question that I have posted.
    Am I using the right way................or which is the best way to store form fields into the session and later retrieve them.
    please reply
    Thanks
    Amitindia

  • How to delete the data loaded into MySQL target table using Scripts

    Hi Experts
    I created a Job with a validation transformation. If the Validation was failed the data passed the validation will be loaded into Pass table and the data failed will be loaded into failed table.
    My requirement was if the data was loaded into Failed database table then i have to delete the data loaded into the Passed table using Script.
    But in the script i have written the code as
    sql('database','delete from <tablename>');
    but as it is an SQL Query execution it is rising exception for the query.
    How can i delete the data loaded into MySQL Target table using scripts.
    Please guide me for this error
    Thanks in Advance
    PrasannaKumar

    Hi Dirk Venken
    I got the Solution, the mistake i did was the query is not correct regarding MySQL.
    sql('MySQL', 'truncate world.customer_salesfact_details')
    error query
    sql('MySQL', 'delete table world.customer_salesfact_details')
    Thanks for your concern
    PrasannaKumar

Maybe you are looking for