Automated emails

T

tshad

I am trying to figure out the best way to send automated emails?

I have emails that I want to send out to certain clients that need them
either daily or weekly.

How would I do in asp.net?

Or is it better to write normal app to handle this that I run from the
schedular?

Thanks,

Tom
 
T

tshad

Juan T. Llibre said:
re:

You can build Windows Services with *any* version of VS.NET.

I have a class that I use for my emails as a namespace for my asp.net
program. It accesses my Sql Server as well as uses the CDO to send the mail
from my asp.net server (W2003 server).

Can I use this .dll for my Windows Service?

The Source looks something like:

******************************************************************
Imports System
Imports System.Web
Imports System.IO
Imports System.Web.UI
Imports System.Web.SessionState
Imports System.Web.Mail
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.HttpCookie
Imports System.Web.HttpCookieCollection
Imports System.Web.HttpResponse
Imports System.Web.HttpRequest
imports System.Web.HttpContext
Imports System.Web.HttpApplication
Imports System.Web.HttpApplicationState
Imports Microsoft.VisualBasic

NameSpace MyFunctions

Public Class Email

Public Shared sub sendEmail ( body as string, emailType as string,
emailTitle as String)
dim webMasterEmail As String
dim emailSubject As String
Dim mailServer As String
Dim contactEmail As String
Dim screenTestSubject As String
Dim subject as String

Dim emailReader As SqlDataReader

Dim ConnectionString as String
=System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_mydatabase")
Dim objConn as New SqlConnection (ConnectionString)
Dim CommandText as String = "Select
MailServer,WebMasterEmail,ContactEmail,ScreenTestSubject,ResumeSubject from
emailResponse where ClientID = '1234'"
Dim objCmd as New SqlCommand(CommandText,objConn)

objConn.Open()

emailReader = objCmd.ExecuteReader

if emailReader.Read then
mailServer = emailReader("MailServer")
webMasterEmail = emailReader("WebMasterEmail")
contactEmail = emailReader("ContactEmail")
subject = emailReader("ScreenTestSubject")
select case emailType
case "Resume"
subject = emailReader("resumeSubject")
end Select
end If

objConn.close()

dim URLPath As String = _
Left(Current.request.path, InStrRev(Current.request.path, "/") - 1)

Dim objStreamReader as StreamReader
Dim strInput As String
Dim strBuffer As String

If
File.exists(Current.Server.MapPath("..\..\automail\new_account_automail.htm"))
then
objStreamReader =
File.OpenText(Current.Server.MapPath("..\..\automail\new_account_automail.htm"))
strInput = objStreamReader.ReadLine()
while strInput <> nothing
strBuffer = strBuffer & strInput
strInput = objStreamReader.ReadLine()
end while
objStreamReader.Close
end if

Dim Message As New MailMessage()
message.To = contactEmail
message.From = webMasterEmail
message.Subject = subject
message.body = body
strInput = strBuffer.replace("#MESSAGE#",message.Body)
strInput = strInput.replace("#MAILTITLE#",emailTitle)
message.Body = strInput
message.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer = mailServer
smtpMail.Send(message)
end sub

end class
end NameSpace
******************************************************************

I compile it from the command line:

vbc /t:library email.vb /r:system.web.dll /r:system.data.dll /r:system.dll
/r:Microsoft.VisualBasic.dll

Would I need to take out the web stuff to make it work?

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top