Email from Access (1 Viewer)

K

kazzy

Guest
I'm an A Level computing student doing my coursework and I've got a problem. I am making a product support system, which will track problems with the product and send out emails to remind clients to renew their licenses.

Each day all the people who need to renew their licenses in a months time will have an email sent to them. I have a field to store all the dates that each client needs reminding.

My problem is that I can't figure out how to extract the email addresses from my access database table and put them into the To: or Bcc: lines in outlook. I also want to put predefined text into the main body of the email.

Please help it's due in soon!
 

Robert Dunstan

Mr Data
Local time
Today, 08:57
Joined
Jun 22, 2000
Messages
291
Hi there,

You need to use the SendObject action. Here is an example of the code I'm using:

Private Sub cmdEmail_Click()

Dim strAddress As String
Dim strDocName As String

strMessage = "You are about e-mail Order Number " & Me.OrderID & Me.Initials
strMessage = strMessage & vbCr & vbCr
strMessage = strMessage & "Please note this will be a text version ONLY (i.e contains no graphics)."
strMessage = strMessage & "The order will be attached to an E-mail message and will not be sent "
strMessage = strMessage & "until you click send. You can view the attachment by double clicking on it." & vbCr & vbCr
strMessage = strMessage & "Do you wish to continue?"
style = vbCritical + vbYesNo + vbDefaultButton1
strTitle = "Sending E-mail"

Response = MsgBox(strMessage, style, strTitle)

If Response = vbNo Then
Exit Sub
Else
On Error GoTo ErrorHandler:

strAddress = Me.txtEmail
strDocName = "rptEmailNewOrder"
strMessage = "Please find attached our purchase order."
strTitle = "Seacore Purchase Order"

DoCmd.SendObject acSendReport, strDocName, "rtf", strAddress, , , strTitle, strMessage, True
End If

Exit Sub

ErrorHandler:
Select Case Err.Number
Case 2293 'Can't send this e-mail
strMessage = "Please launch 'Outlook' then try clicking the 'E-mail' button again "
strMessage = strMessage & "on the New Order screen."
strTitle = "Launch Outlook"
style = vbInformation

MsgBox strMessage, style, strTitle
Response = acDataErrContinue
End Select

End Sub


This should point you in the right direction also have a look at Access help.
 

Users who are viewing this thread

Top Bottom