473,763 Members | 6,638 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

email being sent, but no message

I have setup an email notifications system, that basically takes each
row from a table and sents out an email according to the data in that
row. The emails get sent, with the subject being filled as expected.
Only problem is that sometimes there is no message.

Here is the stored procedure that is being called every hour to send
the emails:

CREATE PROCEDURE dbo.RemindersSe ndEmails AS

--Cursor
DECLARE RemindersCursor CURSOR FOR
SELECT *
FROM RemindersTodays AndUnsent

--Values for cursor
DECLARE
@I_Reminder_ID bigint,
@I_Notice_ID bigint,
@V_Reminder_Tex t varchar(250),
@SDT_Reminder_D ate smalldatetime,
@V_Email varchar(50),
@I_Reminder_Typ e bigint,
@SDT_Reminder_S ent smalldatetime,
@I_Attempts_Mad e int,
@V_Notice_Type varchar(50),
@I_Notice_Perio d int,
@V_Period_Descr iption varchar(50),
@I_Project_ID bigint,
@V_Notice_Ref varchar(10)

--values for sending the mail
DECLARE @NEWLINE varchar(2)

OPEN RemindersCursor

FETCH NEXT FROM RemindersCursor
INTO @I_Reminder_ID, @I_Notice_ID, @V_Reminder_Tex t,
@SDT_Reminder_D ate, @V_Email, @I_Reminder_Typ e,
@SDT_Reminder_S ent, @I_Attempts_Mad e, @V_Notice_Type,
@I_Notice_Perio d, @V_Period_Descr iption,
@I_Project_ID, @V_Notice_Ref
--INTO @I_Reminder_ID, @I_Notice_ID, @V_Reminder_Tex t,
@SDT_Reminder_D ate, @V_Email, @I_Reminder_Typ e,
-- @SDT_Reminder_S ent, @I_Attempts_Mad e, @V_Notice_Type,
@I_Notice_Perio d, @V_Period_Descr iption,
-- @I_Project_ID, @V_Notice_Ref

SET @NEWLINE = char(10)

--PRINT 'start'

WHILE @@FETCH_STATUS = 0
BEGIN

DECLARE @EmailMessage varchar(6000), @Subject varchar(100), @Status
int

SET @Subject = RTRIM(CONVERT(v archar(8), @I_Reminder_ID) ) + ' Notice
Alert - Project ' + RTRIM(CONVERT(v archar(8), @I_Project_ID)) + '
Notice Ref ' + RTRIM(@V_Notice _Ref)

SET @EmailMessage = 'Project: ' + RTRIM(CONVERT(v archar(8),
@I_Project_ID)) + @NEWLINE +
'Notice: ' + RTRIM(@V_Notice _Ref) + @NEWLINE +
'Notice Type: ' + RTRIM(@V_Notice _Type) + ' - ' +
RTRIM(@V_Period _Description) + @NEWLINE +
'Reminder: ' + RTRIM(@V_Remind er_Text) + @NEWLINE + @NEWLINE +
'Reminder date: ' + CONVERT(varchar (11), @SDT_Reminder_D ate) +
@NEWLINE +
'Reminder sent: ' + CONVERT(varchar (11), GETDATE()) + @NEWLINE +
'Email sent to: ' + @V_Email + @NEWLINE +
'Number of attempts made at sending this email (once every hour): '
+ CONVERT(varchar (4), @I_Attempts_Mad e)
--@I_Reminder_ID, @I_Notice_ID, @V_Email, @I_Reminder_Typ e,
@I_Notice_Perio d,

PRINT 'subject = ' + @Subject
PRINT 'message = ' + @EmailMessage

SET @V_Email = LTRIM(RTRIM(@V_ Email))

EXEC @Status = master..xp_send mail @recipients = @V_Email,
@message = @EmailMessage,
@subject = @Subject

--PRINT 'XXXXXXXXXXXXXX XXXXXXXX status = ' + CONVERT(varchar (2),
@Status)

--If send mail is a success
IF (@Status = 0)
BEGIN
UPDATE Reminders
SET SDT_Reminder_Se nt = GETDATE(), I_Attempts_Made =
@I_Attempts_Mad e + 1
WHERE I_Reminder_ID = @I_Reminder_ID
END
--Else send mail failed
ELSE
BEGIN
UPDATE Reminders
SET I_Attempts_Made = @I_Attempts_Mad e + 1
WHERE I_Reminder_ID = @I_Reminder_ID
END
-- Get the next reminder
FETCH NEXT FROM RemindersCursor
INTO @I_Reminder_ID, @I_Notice_ID, @V_Reminder_Tex t,
@SDT_Reminder_D ate, @V_Email, @I_Reminder_Typ e,
@SDT_Reminder_S ent, @I_Attempts_Mad e, @V_Notice_Type,
@I_Notice_Perio d, @V_Period_Descr iption,
@I_Project_ID, @V_Notice_Ref
END

--PRINT 'End'

CLOSE RemindersCursor
DEALLOCATE RemindersCursor
GO
Jul 20 '05 #1
2 1687
Just a guess-- I'd check to see if any of your variables are NULL the SET
statement that builds your @EmailMessage variable. In that case maybe your
entire @EmailMessage variable is getting set to NULL?

"Jagdip Singh Ajimal" <js*****@hotmai l.com> wrote in message
news:c8******** *************** ***@posting.goo gle.com...
I have setup an email notifications system, that basically takes each
row from a table and sents out an email according to the data in that
row. The emails get sent, with the subject being filled as expected.
Only problem is that sometimes there is no message.

Here is the stored procedure that is being called every hour to send
the emails:

CREATE PROCEDURE dbo.RemindersSe ndEmails AS

--Cursor
DECLARE RemindersCursor CURSOR FOR
SELECT *
FROM RemindersTodays AndUnsent

--Values for cursor
DECLARE
@I_Reminder_ID bigint,
@I_Notice_ID bigint,
@V_Reminder_Tex t varchar(250),
@SDT_Reminder_D ate smalldatetime,
@V_Email varchar(50),
@I_Reminder_Typ e bigint,
@SDT_Reminder_S ent smalldatetime,
@I_Attempts_Mad e int,
@V_Notice_Type varchar(50),
@I_Notice_Perio d int,
@V_Period_Descr iption varchar(50),
@I_Project_ID bigint,
@V_Notice_Ref varchar(10)

--values for sending the mail
DECLARE @NEWLINE varchar(2)

OPEN RemindersCursor

FETCH NEXT FROM RemindersCursor
INTO @I_Reminder_ID, @I_Notice_ID, @V_Reminder_Tex t,
@SDT_Reminder_D ate, @V_Email, @I_Reminder_Typ e,
@SDT_Reminder_S ent, @I_Attempts_Mad e, @V_Notice_Type,
@I_Notice_Perio d, @V_Period_Descr iption,
@I_Project_ID, @V_Notice_Ref
--INTO @I_Reminder_ID, @I_Notice_ID, @V_Reminder_Tex t,
@SDT_Reminder_D ate, @V_Email, @I_Reminder_Typ e,
-- @SDT_Reminder_S ent, @I_Attempts_Mad e, @V_Notice_Type,
@I_Notice_Perio d, @V_Period_Descr iption,
-- @I_Project_ID, @V_Notice_Ref

SET @NEWLINE = char(10)

--PRINT 'start'

WHILE @@FETCH_STATUS = 0
BEGIN

DECLARE @EmailMessage varchar(6000), @Subject varchar(100), @Status
int

SET @Subject = RTRIM(CONVERT(v archar(8), @I_Reminder_ID) ) + ' Notice
Alert - Project ' + RTRIM(CONVERT(v archar(8), @I_Project_ID)) + '
Notice Ref ' + RTRIM(@V_Notice _Ref)

SET @EmailMessage = 'Project: ' + RTRIM(CONVERT(v archar(8),
@I_Project_ID)) + @NEWLINE +
'Notice: ' + RTRIM(@V_Notice _Ref) + @NEWLINE +
'Notice Type: ' + RTRIM(@V_Notice _Type) + ' - ' +
RTRIM(@V_Period _Description) + @NEWLINE +
'Reminder: ' + RTRIM(@V_Remind er_Text) + @NEWLINE + @NEWLINE +
'Reminder date: ' + CONVERT(varchar (11), @SDT_Reminder_D ate) +
@NEWLINE +
'Reminder sent: ' + CONVERT(varchar (11), GETDATE()) + @NEWLINE +
'Email sent to: ' + @V_Email + @NEWLINE +
'Number of attempts made at sending this email (once every hour): '
+ CONVERT(varchar (4), @I_Attempts_Mad e)
--@I_Reminder_ID, @I_Notice_ID, @V_Email, @I_Reminder_Typ e,
@I_Notice_Perio d,

PRINT 'subject = ' + @Subject
PRINT 'message = ' + @EmailMessage

SET @V_Email = LTRIM(RTRIM(@V_ Email))

EXEC @Status = master..xp_send mail @recipients = @V_Email,
@message = @EmailMessage,
@subject = @Subject

--PRINT 'XXXXXXXXXXXXXX XXXXXXXX status = ' + CONVERT(varchar (2),
@Status)

--If send mail is a success
IF (@Status = 0)
BEGIN
UPDATE Reminders
SET SDT_Reminder_Se nt = GETDATE(), I_Attempts_Made =
@I_Attempts_Mad e + 1
WHERE I_Reminder_ID = @I_Reminder_ID
END
--Else send mail failed
ELSE
BEGIN
UPDATE Reminders
SET I_Attempts_Made = @I_Attempts_Mad e + 1
WHERE I_Reminder_ID = @I_Reminder_ID
END
-- Get the next reminder
FETCH NEXT FROM RemindersCursor
INTO @I_Reminder_ID, @I_Notice_ID, @V_Reminder_Tex t,
@SDT_Reminder_D ate, @V_Email, @I_Reminder_Typ e,
@SDT_Reminder_S ent, @I_Attempts_Mad e, @V_Notice_Type,
@I_Notice_Perio d, @V_Period_Descr iption,
@I_Project_ID, @V_Notice_Ref
END

--PRINT 'End'

CLOSE RemindersCursor
DEALLOCATE RemindersCursor
GO

Jul 20 '05 #2

"MissLivvy" <Xe************ *******@yahoo.c om> wrote in message
news:je******** *********@newsr ead3.news.pas.e arthlink.net...
Just a guess-- I'd check to see if any of your variables are NULL the SET
statement that builds your @EmailMessage variable. In that case maybe your
entire @EmailMessage variable is getting set to NULL?

Ah good one.

This got me once. I forgot abuot it.
"Jagdip Singh Ajimal" <js*****@hotmai l.com> wrote in message
news:c8******** *************** ***@posting.goo gle.com...
I have setup an email notifications system, that basically takes each
row from a table and sents out an email according to the data in that
row. The emails get sent, with the subject being filled as expected.
Only problem is that sometimes there is no message.

Here is the stored procedure that is being called every hour to send
the emails:

CREATE PROCEDURE dbo.RemindersSe ndEmails AS

--Cursor
DECLARE RemindersCursor CURSOR FOR
SELECT *
FROM RemindersTodays AndUnsent

--Values for cursor
DECLARE
@I_Reminder_ID bigint,
@I_Notice_ID bigint,
@V_Reminder_Tex t varchar(250),
@SDT_Reminder_D ate smalldatetime,
@V_Email varchar(50),
@I_Reminder_Typ e bigint,
@SDT_Reminder_S ent smalldatetime,
@I_Attempts_Mad e int,
@V_Notice_Type varchar(50),
@I_Notice_Perio d int,
@V_Period_Descr iption varchar(50),
@I_Project_ID bigint,
@V_Notice_Ref varchar(10)

--values for sending the mail
DECLARE @NEWLINE varchar(2)

OPEN RemindersCursor

FETCH NEXT FROM RemindersCursor
INTO @I_Reminder_ID, @I_Notice_ID, @V_Reminder_Tex t,
@SDT_Reminder_D ate, @V_Email, @I_Reminder_Typ e,
@SDT_Reminder_S ent, @I_Attempts_Mad e, @V_Notice_Type,
@I_Notice_Perio d, @V_Period_Descr iption,
@I_Project_ID, @V_Notice_Ref
--INTO @I_Reminder_ID, @I_Notice_ID, @V_Reminder_Tex t,
@SDT_Reminder_D ate, @V_Email, @I_Reminder_Typ e,
-- @SDT_Reminder_S ent, @I_Attempts_Mad e, @V_Notice_Type,
@I_Notice_Perio d, @V_Period_Descr iption,
-- @I_Project_ID, @V_Notice_Ref

SET @NEWLINE = char(10)

--PRINT 'start'

WHILE @@FETCH_STATUS = 0
BEGIN

DECLARE @EmailMessage varchar(6000), @Subject varchar(100), @Status
int

SET @Subject = RTRIM(CONVERT(v archar(8), @I_Reminder_ID) ) + ' Notice
Alert - Project ' + RTRIM(CONVERT(v archar(8), @I_Project_ID)) + '
Notice Ref ' + RTRIM(@V_Notice _Ref)

SET @EmailMessage = 'Project: ' + RTRIM(CONVERT(v archar(8),
@I_Project_ID)) + @NEWLINE +
'Notice: ' + RTRIM(@V_Notice _Ref) + @NEWLINE +
'Notice Type: ' + RTRIM(@V_Notice _Type) + ' - ' +
RTRIM(@V_Period _Description) + @NEWLINE +
'Reminder: ' + RTRIM(@V_Remind er_Text) + @NEWLINE + @NEWLINE +
'Reminder date: ' + CONVERT(varchar (11), @SDT_Reminder_D ate) +
@NEWLINE +
'Reminder sent: ' + CONVERT(varchar (11), GETDATE()) + @NEWLINE +
'Email sent to: ' + @V_Email + @NEWLINE +
'Number of attempts made at sending this email (once every hour): '
+ CONVERT(varchar (4), @I_Attempts_Mad e)
--@I_Reminder_ID, @I_Notice_ID, @V_Email, @I_Reminder_Typ e,
@I_Notice_Perio d,

PRINT 'subject = ' + @Subject
PRINT 'message = ' + @EmailMessage

SET @V_Email = LTRIM(RTRIM(@V_ Email))

EXEC @Status = master..xp_send mail @recipients = @V_Email,
@message = @EmailMessage,
@subject = @Subject

--PRINT 'XXXXXXXXXXXXXX XXXXXXXX status = ' + CONVERT(varchar (2),
@Status)

--If send mail is a success
IF (@Status = 0)
BEGIN
UPDATE Reminders
SET SDT_Reminder_Se nt = GETDATE(), I_Attempts_Made =
@I_Attempts_Mad e + 1
WHERE I_Reminder_ID = @I_Reminder_ID
END
--Else send mail failed
ELSE
BEGIN
UPDATE Reminders
SET I_Attempts_Made = @I_Attempts_Mad e + 1
WHERE I_Reminder_ID = @I_Reminder_ID
END
-- Get the next reminder
FETCH NEXT FROM RemindersCursor
INTO @I_Reminder_ID, @I_Notice_ID, @V_Reminder_Tex t,
@SDT_Reminder_D ate, @V_Email, @I_Reminder_Typ e,
@SDT_Reminder_S ent, @I_Attempts_Mad e, @V_Notice_Type,
@I_Notice_Perio d, @V_Period_Descr iption,
@I_Project_ID, @V_Notice_Ref
END

--PRINT 'End'

CLOSE RemindersCursor
DEALLOCATE RemindersCursor
GO


Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
1911
by: JayB | last post by:
We sent out an email today to a list of subscribers from our database using ASP and CDO. For some reason, many people received it twice, including myself. I checked the database and there were do duplicate records and I know for sure that I have no other email address forwarding email. I checked my code and all seems ok. Perhaps someone can take a look at it and see if I screwed up somewhere? It was sent to over 9,000 email addresses. When...
117
11885
by: Steevo | last post by:
Any suggestions as to the best programs for cloaking email addresses? Many thanks -- Steevo
1
1480
by: WillWeGetOurFreedomBack | last post by:
Here is the text of an email I recently received from a user of our Access 2K application. This is totally baffling to me. "WXYZ" = the name of our program for the purpose of this message. "What I did was I sent every email in my WXYZ to myself. Interestingly, most of the emails delivered. Out of 18, 6 wouldn’t deliver. I tried changing the subject verbiage and then it delivered to my inbox. Therefore, there’s an email filter...
1
2094
by: bidllc | last post by:
I'm working on a minor bug from an open source bug tracking system (bugtracket.net). It's a great app, but I don't want to bother the creator any more than I have to, so I thought I'd pose the question here. The problem is with an email that gets sent from the system. In a nutshell, it's an HTML format email that is choking on the string that is returned form this function that is added to the email's body:
3
1530
by: Nicola | last post by:
When using the NewMail.Body object, ! and spaces are being added into the email after the email has been sent. Has anyone else had this problem or even better a solution??
4
1975
by: elampirai | last post by:
Hi, I did a feedback form in PHP. When i click the submit button, the form is submitted and the mail has been sent successfully and all the fields had been clear. But then if i click the refresh button, automatically a mail is sent with the previous data. Can anyone help me out. Here is the Code: ----------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head>
1
5038
by: shapper | last post by:
Hello, I created an ASP.NET 2.0 custom control which includes various TextBoxes, Labels and a button. Basically is a contact form. When the button is pressed the values are sent by email. I want to use the mailSettings values in my Web.Config file. Everything works fine if I use in my bSubmit function:
8
4487
by: alice | last post by:
I found this code for making a php email form for a web site. It works fine on my ISP, but not on my friends...could it be that my ISP uses php5, I know that hers does not, so I assume it's php4. Is there anyway to tell? Here's the code. It sends me email fine, but when it's on her ISP, it says it sent the mail, but nothing goes through. <?php if (isset($submit)) { switch ($recipient) { case "whole-family":
2
2271
by: ssmeshack | last post by:
Hai there, I have doing php code for form data to be send to email. But it is showing... Here is my code for html form... <body>
0
9387
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10002
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9823
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8822
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3528
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.