If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > send emails

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-13-08, 17:24
wisdom2004 wisdom2004 is offline
Registered User
 
Join Date: Sep 2008
Posts: 13
send emails

Hi,
Hope everyone is doing good.
this is my first post in the forum and i find it great. i have a database that i use to send mass emails to agents that have cases on thier queue basiclly i run just a macro and macro run a function than emails start sending through outlook that should be open, everything works fine and never have a problem, now what i would like to do is to send mass email in HTML format using ASP, below is the code i use in access.

Thanks.
____________________________
Function SEmail()

On Error GoTo ErrorHandler

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim Outlook As Outlook.Application
Dim Email As Outlook.MailItem
Dim sSubject As String
Dim sBody As String
Dim fso As FileSystemObject
Dim Body As TextStream
Dim BodyText As String

'set Outlook
Set Outlook = New Outlook.Application

'set up the database and query connections
Set db = CurrentDb()

'warnings OFF
DoCmd.SetWarnings False

'clear working table
Call DeleteTable("tSendEmails")

'warnings OFF
DoCmd.SetWarnings False

'add data to working table
DoCmd.OpenQuery "qaSendEmails"

'warnings ON
DoCmd.SetWarnings True

'set query/recordset
Set rs = db.OpenRecordset("tSendEmails", dbOpenDynaset)

'loop through our list of addresses,
'adding them to e-mails and sending them.
Do Until rs.EOF

'create the e-mail
Set Email = Outlook.CreateItem(olMailItem)

'address the e-mail
Email.To = rs("Email")

'subject of the e-mail
Email.Subject = "Case on Your Queue"

'body of the e-mail message
Email.Body = "Dear " & VBA.Trim(rs("AgentName")) & ":"
Email.Body = Email.Body & vbCrLf
Email.Body = Email.Body & vbCrLf
Email.Body = Email.Body & EmailText(8)
Email.Body = Email.Body & vbCrLf
Email.Body = Email.Body & vbCrLf
Email.Body = Email.Body & rs("CaseID")
Email.Body = Email.Body & vbCrLf
Email.Body = Email.Body & vbCrLf
Email.Body = Email.Body & EmailText(9)

'flag e-mail as confidential
Email.Sensitivity = olConfidential

'flag e-mail as read receipt requested
'Email.ReadReceiptRequested = True

'send e-mail
Email.Send

Out:
'move to the next one
rs.MoveNext

Loop

MsgBox "Email Process Complete"

rs.Close
db.Close

Set Email = Nothing
Set Outlook = Nothing
Set rs = Nothing
Set db = Nothing

Exit Function

ErrorHandler:
'Error handler will be used to flag job table when Outlook cannot send an
'e-mail because e-mail address is invalid

rs.Edit
rs("Invalid") = True
rs.Update
Resume Out

End Function
Reply With Quote
  #2 (permalink)  
Old 09-13-08, 18:21
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
@respondents - FYI:
Send Mass Emails
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #3 (permalink)  
Old 09-13-08, 20:47
wisdom2004 wisdom2004 is offline
Registered User
 
Join Date: Sep 2008
Posts: 13
I want to do it in Access First, knowing it in ASP that my future plan to create webpage to send mass emails
Reply With Quote
  #4 (permalink)  
Old 09-15-08, 22:25
Bullschmidt Bullschmidt is offline
Guru
 
Join Date: Jun 2003
Location: USA
Posts: 1,032
Here's a handly link for sending a single e-mail and of course something like this could be done within a recordset loop to send multiple e-mails perhaps up to there is a timeout:

ASP Sending e-mail with CDOSYS
http://www.w3schools.com/asp/asp_send_email.asp
__________________
J. Paul Schmidt, Freelance Web and Database Developer
www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On