Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Access to send Emails through Outlook

Status
Not open for further replies.

brharrii

Technical User
Feb 26, 2013
1
US
I have a subform in tabular view that lists the names of auditors who have not submitted their monthly reports yet. I'd to add a button next to the auditor name that says "Email for Update" or something to that extent. At that point access would look to the auditor table, find the corresponding email address, and email a request to the auditor to get their report in asap.

Could anyone assist me with this?

thanks!
 
You'd have to code it in vba, this is pretty bare bones, but you would plug this code into the click event of a button on a form:

Private Sub MyButton_Click()

Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("ListOfAuditorsTable")
With rs
If .EOF And .BOF Then
MsgBox "No emails will be sent becuase there are no records assigned from the list", vbInformation
Else
Do Until .EOF
stremail = !
strsubject = ![address]
strbody = "Dear " & ![name] & "," & _
Chr(10) & Chr(10) & "Some kind of greeting" & ![address] & "!" & _
" email message body goes here"

'.Edit
'.Update

Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = stremail
.CC = "someITguy@company.com"
.BCC = ""
.Subject = strsubject
.Body = strbody

.SendUsingAccount = OutApp.Session.Accounts.Item(2)
.Send
End With
.MoveNext
Loop

End If
End With

End sub

Should work with any version of Access.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top