473,326 Members | 2,175 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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.RemindersSendEmails AS

--Cursor
DECLARE RemindersCursor CURSOR FOR
SELECT *
FROM RemindersTodaysAndUnsent

--Values for cursor
DECLARE
@I_Reminder_ID bigint,
@I_Notice_ID bigint,
@V_Reminder_Text varchar(250),
@SDT_Reminder_Date smalldatetime,
@V_Email varchar(50),
@I_Reminder_Type bigint,
@SDT_Reminder_Sent smalldatetime,
@I_Attempts_Made int,
@V_Notice_Type varchar(50),
@I_Notice_Period int,
@V_Period_Description 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_Text,
@SDT_Reminder_Date, @V_Email, @I_Reminder_Type,
@SDT_Reminder_Sent, @I_Attempts_Made, @V_Notice_Type,
@I_Notice_Period, @V_Period_Description,
@I_Project_ID, @V_Notice_Ref
--INTO @I_Reminder_ID, @I_Notice_ID, @V_Reminder_Text,
@SDT_Reminder_Date, @V_Email, @I_Reminder_Type,
-- @SDT_Reminder_Sent, @I_Attempts_Made, @V_Notice_Type,
@I_Notice_Period, @V_Period_Description,
-- @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(varchar(8), @I_Reminder_ID)) + ' Notice
Alert - Project ' + RTRIM(CONVERT(varchar(8), @I_Project_ID)) + '
Notice Ref ' + RTRIM(@V_Notice_Ref)

SET @EmailMessage = 'Project: ' + RTRIM(CONVERT(varchar(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_Reminder_Text) + @NEWLINE + @NEWLINE +
'Reminder date: ' + CONVERT(varchar(11), @SDT_Reminder_Date) +
@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_Made)
--@I_Reminder_ID, @I_Notice_ID, @V_Email, @I_Reminder_Type,
@I_Notice_Period,

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

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

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

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

--If send mail is a success
IF (@Status = 0)
BEGIN
UPDATE Reminders
SET SDT_Reminder_Sent = GETDATE(), I_Attempts_Made =
@I_Attempts_Made + 1
WHERE I_Reminder_ID = @I_Reminder_ID
END
--Else send mail failed
ELSE
BEGIN
UPDATE Reminders
SET I_Attempts_Made = @I_Attempts_Made + 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_Text,
@SDT_Reminder_Date, @V_Email, @I_Reminder_Type,
@SDT_Reminder_Sent, @I_Attempts_Made, @V_Notice_Type,
@I_Notice_Period, @V_Period_Description,
@I_Project_ID, @V_Notice_Ref
END

--PRINT 'End'

CLOSE RemindersCursor
DEALLOCATE RemindersCursor
GO
Jul 20 '05 #1
2 1663
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*****@hotmail.com> wrote in message
news:c8**************************@posting.google.c om...
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.RemindersSendEmails AS

--Cursor
DECLARE RemindersCursor CURSOR FOR
SELECT *
FROM RemindersTodaysAndUnsent

--Values for cursor
DECLARE
@I_Reminder_ID bigint,
@I_Notice_ID bigint,
@V_Reminder_Text varchar(250),
@SDT_Reminder_Date smalldatetime,
@V_Email varchar(50),
@I_Reminder_Type bigint,
@SDT_Reminder_Sent smalldatetime,
@I_Attempts_Made int,
@V_Notice_Type varchar(50),
@I_Notice_Period int,
@V_Period_Description 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_Text,
@SDT_Reminder_Date, @V_Email, @I_Reminder_Type,
@SDT_Reminder_Sent, @I_Attempts_Made, @V_Notice_Type,
@I_Notice_Period, @V_Period_Description,
@I_Project_ID, @V_Notice_Ref
--INTO @I_Reminder_ID, @I_Notice_ID, @V_Reminder_Text,
@SDT_Reminder_Date, @V_Email, @I_Reminder_Type,
-- @SDT_Reminder_Sent, @I_Attempts_Made, @V_Notice_Type,
@I_Notice_Period, @V_Period_Description,
-- @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(varchar(8), @I_Reminder_ID)) + ' Notice
Alert - Project ' + RTRIM(CONVERT(varchar(8), @I_Project_ID)) + '
Notice Ref ' + RTRIM(@V_Notice_Ref)

SET @EmailMessage = 'Project: ' + RTRIM(CONVERT(varchar(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_Reminder_Text) + @NEWLINE + @NEWLINE +
'Reminder date: ' + CONVERT(varchar(11), @SDT_Reminder_Date) +
@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_Made)
--@I_Reminder_ID, @I_Notice_ID, @V_Email, @I_Reminder_Type,
@I_Notice_Period,

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

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

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

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

--If send mail is a success
IF (@Status = 0)
BEGIN
UPDATE Reminders
SET SDT_Reminder_Sent = GETDATE(), I_Attempts_Made =
@I_Attempts_Made + 1
WHERE I_Reminder_ID = @I_Reminder_ID
END
--Else send mail failed
ELSE
BEGIN
UPDATE Reminders
SET I_Attempts_Made = @I_Attempts_Made + 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_Text,
@SDT_Reminder_Date, @V_Email, @I_Reminder_Type,
@SDT_Reminder_Sent, @I_Attempts_Made, @V_Notice_Type,
@I_Notice_Period, @V_Period_Description,
@I_Project_ID, @V_Notice_Ref
END

--PRINT 'End'

CLOSE RemindersCursor
DEALLOCATE RemindersCursor
GO

Jul 20 '05 #2

"MissLivvy" <Xe*******************@yahoo.com> wrote in message
news:je*****************@newsread3.news.pas.earthl ink.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*****@hotmail.com> wrote in message
news:c8**************************@posting.google.c om...
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.RemindersSendEmails AS

--Cursor
DECLARE RemindersCursor CURSOR FOR
SELECT *
FROM RemindersTodaysAndUnsent

--Values for cursor
DECLARE
@I_Reminder_ID bigint,
@I_Notice_ID bigint,
@V_Reminder_Text varchar(250),
@SDT_Reminder_Date smalldatetime,
@V_Email varchar(50),
@I_Reminder_Type bigint,
@SDT_Reminder_Sent smalldatetime,
@I_Attempts_Made int,
@V_Notice_Type varchar(50),
@I_Notice_Period int,
@V_Period_Description 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_Text,
@SDT_Reminder_Date, @V_Email, @I_Reminder_Type,
@SDT_Reminder_Sent, @I_Attempts_Made, @V_Notice_Type,
@I_Notice_Period, @V_Period_Description,
@I_Project_ID, @V_Notice_Ref
--INTO @I_Reminder_ID, @I_Notice_ID, @V_Reminder_Text,
@SDT_Reminder_Date, @V_Email, @I_Reminder_Type,
-- @SDT_Reminder_Sent, @I_Attempts_Made, @V_Notice_Type,
@I_Notice_Period, @V_Period_Description,
-- @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(varchar(8), @I_Reminder_ID)) + ' Notice
Alert - Project ' + RTRIM(CONVERT(varchar(8), @I_Project_ID)) + '
Notice Ref ' + RTRIM(@V_Notice_Ref)

SET @EmailMessage = 'Project: ' + RTRIM(CONVERT(varchar(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_Reminder_Text) + @NEWLINE + @NEWLINE +
'Reminder date: ' + CONVERT(varchar(11), @SDT_Reminder_Date) +
@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_Made)
--@I_Reminder_ID, @I_Notice_ID, @V_Email, @I_Reminder_Type,
@I_Notice_Period,

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

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

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

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

--If send mail is a success
IF (@Status = 0)
BEGIN
UPDATE Reminders
SET SDT_Reminder_Sent = GETDATE(), I_Attempts_Made =
@I_Attempts_Made + 1
WHERE I_Reminder_ID = @I_Reminder_ID
END
--Else send mail failed
ELSE
BEGIN
UPDATE Reminders
SET I_Attempts_Made = @I_Attempts_Made + 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_Text,
@SDT_Reminder_Date, @V_Email, @I_Reminder_Type,
@SDT_Reminder_Sent, @I_Attempts_Made, @V_Notice_Type,
@I_Notice_Period, @V_Period_Description,
@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
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...
117
by: Steevo | last post by:
Any suggestions as to the best programs for cloaking email addresses? Many thanks -- Steevo
1
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. ...
1
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...
3
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
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...
1
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...
8
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....
2
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.