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