473,386 Members | 1,705 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,386 software developers and data experts.

Automated email

Hi,

I want to send automated emails. I want to send emails to some persons in the table at the end of the day like 10.00 pm every day. How do I do that?
I am using sql server 2000 and asp.net.

Thanks in advance for the reply.
Jun 5 '06 #1
5 5963
Use the following syntax to send email
SendEMail 'softdev@knoahindia.com','prasad@knoahindia.com', 'Sending email through Stored Procedure', 'Body : Giving TO, FROM, SUBJECT, BODY, SMTP - Address - 192.168.0.5, An Email can be sent through stored procedure... and this is SAMPLE', '192.168.0.5'

Here is the storedprocedure
Create Procedure dbo.SendEmail
@To VarChar(500), @From VarChar(100), @Subject VarChar(200), @Body VarChar(1000), @SMTPServer VarChar(50)
AS
Declare @Object int, @Hr int, @Src VarChar(255), @Desc VarChar(255)
--Create Message object
Exec @Hr = sp_OACreate 'CDO.Message', @Object OUT
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object, @Src OUT, @Desc OUT
SELECT hr=convert(varbinary(4),@Hr), Source=@Src, Description=@Desc
Return
End
--set sEndusing property
Exec @Hr = sp_OASetProperty @Object, 'Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sEndusing")', '2'
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object
Return
End
--set port property
Exec @Hr = sp_OASetProperty @Object, 'Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/SEndUsingMethod")', '25'
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object
Return
End
--set smtp server property
Exec @Hr = sp_OASetProperty @Object, 'Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")', @SMTPServer
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object
Return
End
--Update the configuration
Exec @Hr = sp_OAMethod @Object, 'Configuration.Fields.Update', Null
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object
Return
End
--set TO property
Exec @Hr = sp_OASetProperty @Object, 'To', @To
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object
Return
End
--set FROM property
Exec @Hr = sp_OASetProperty @Object, 'From', @From
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object
Return
End
--set Subject property
Exec @Hr = sp_OASetProperty @Object, 'Subject', @Subject
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object
Return
End
--set HTMLBody property
Exec @Hr = sp_OASetProperty @Object, 'HTMLBody', @Body
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object
Return
End
--SEnd the mail
Exec @Hr = sp_OAMethod @Object, 'SEnd', Null
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object
Return
End
--No memory leaks!
Exec @Hr = sp_OADestroy @Object
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object
Return
End
Jul 6 '06 #2
Use the following syntax to send email
SendEMail 'softdev@knoahindia.com','prasad@knoahindia.com', 'Sending email through Stored Procedure', 'Body : Giving TO, FROM, SUBJECT, BODY, SMTP - Address - 192.168.0.5, An Email can be sent through stored procedure... and this is SAMPLE', '192.168.0.5'

Here is the storedprocedure
Create Procedure dbo.SendEmail
@To VarChar(500), @From VarChar(100), @Subject VarChar(200), @Body VarChar(1000), @SMTPServer VarChar(50)
AS
Declare @Object int, @Hr int, @Src VarChar(255), @Desc VarChar(255)
--Create Message object
Exec @Hr = sp_OACreate 'CDO.Message', @Object OUT
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object, @Src OUT, @Desc OUT
SELECT hr=convert(varbinary(4),@Hr), Source=@Src, Description=@Desc
Return
End
--set sEndusing property
Exec @Hr = sp_OASetProperty @Object, 'Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sEndusing")', '2'
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object
Return
End
--set port property
Exec @Hr = sp_OASetProperty @Object, 'Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/SEndUsingMethod")', '25'
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object
Return
End
--set smtp server property
Exec @Hr = sp_OASetProperty @Object, 'Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")', @SMTPServer
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object
Return
End
--Update the configuration
Exec @Hr = sp_OAMethod @Object, 'Configuration.Fields.Update', Null
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object
Return
End
--set TO property
Exec @Hr = sp_OASetProperty @Object, 'To', @To
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object
Return
End
--set FROM property
Exec @Hr = sp_OASetProperty @Object, 'From', @From
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object
Return
End
--set Subject property
Exec @Hr = sp_OASetProperty @Object, 'Subject', @Subject
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object
Return
End
--set HTMLBody property
Exec @Hr = sp_OASetProperty @Object, 'HTMLBody', @Body
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object
Return
End
--SEnd the mail
Exec @Hr = sp_OAMethod @Object, 'SEnd', Null
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object
Return
End
--No memory leaks!
Exec @Hr = sp_OADestroy @Object
If @Hr <> 0
Begin
Exec sp_OAGetErrorInfo @Object
Return
End

hi,
i am shahnawaz
i use this stored procedure but it give error
"The "SendUsing" configuration value is invalid. "
how can i resolve this problem .
May 28 '07 #3
i want to create a stored procedure to get automated email from my ms sql 2000 database

when a new user register I would like to get a email automatically,
normally all the registered user information is store in user table

please let me know how to do this..

from address shold be the registered member email address


please let me know how do this

Looking to hear from you thanks!
Feb 2 '08 #4
iam willing to pay even a small fee if some can get me a correct solution,

All I want is when a new cutomer register I want to get a email send,

from the database,

Iam using MS sql 2000 data is stores in user table

Thanks
Rafi
Feb 2 '08 #5
Susain
1
HI Friends,

I have used the above procedure and working fine.

How can I use that procedure to My reqiurement i.e., Members need to get membership expiry emails for 3 times (30 days before, on the expiry date and at 60 days) and need to move the member to inactive list after 90 days.

Please Help !

Thanks
Mar 4 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Bengt Richter | last post by:
I find that threads sometimes mention PEPs that I wasn't aware of, or that an interesting one has been updated without my noticing. I should perhaps check the PEP site more regularly, but ISTM it...
3
by: SueHales | last post by:
Hi, folks. I'm fairly new to SQL Server, so forgive any stupidity inherent in this question. I work at a university and a certain faculty member would like to have her students create a simple...
4
by: MLH | last post by:
I would like to configure OutLook Express so that it does not attempt to resend eMails in the Outbox folder whenever new sends are made From Access. The ISP's server rejects some eMail address...
6
by: brettev | last post by:
World, I work at a university where the professors have a system to input grades for assignments and calculate final grades, which is output to an excel file. they are then required to get on a...
2
by: tk | last post by:
Hello, At the moment im building a database for a driving school, I have a customer field, with email address as an attribute. I dont know much about macros in access but once the customer has...
0
by: tonydevlin | last post by:
I currently have the python code obj=sti.object creator = obj.Creator() history = sti.getHistory() wf_tool = context.portal_workflow mMsg = """ Content has been submitted for your review....
7
by: Jeff | last post by:
Hey ..NET 2.0 I'm on a project where I'm now about to develop the Data Access Layer. The database have 300 stored procedures. I'm about to go on a time consuming process of writing the .NET...
1
by: jadeverell | last post by:
Hi, I have a database that contains information of contracts / tenders and need to do the following task: * when a contract reaches its expiry date, i want to send an automated email to notify...
1
by: jadeverell | last post by:
Hi, I have a database that contains a list of contracts including the dates they are due to expire and i was wondering if Access can be set up to send an automated email to an email address that...
12
by: mr_marcin | last post by:
Hi Does anybody have some idea how to input some text into inputbox on one page, than press some button on that page, that will load another page, and finally read the responde? Suppose I want...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.