Code:
Private Sub btnMail1_Click()
Dim strEMail As String
Dim oOutlook As Object
Dim oMail As Object
Dim strAddr As String
Dim MyDB As DAO.Database
Dim rstEMail As DAO.Recordset
Set oOutlook = CreateObject("Outlook.Application")
Set oMail = oOutlook.CreateItem(0)
'Retrieve all E-Mail Addressess in tblEMailAddress
Set MyDB = CurrentDb
Set rstEMail = MyDB.OpenRecordset("Select * From tblEMail", dbOpenSnapshot, dbOpenForwardOnly)
With rstEMail
Do While Not .EOF
'Build the Recipients String
strEMail = strEMail & ![EmailAddress] & ";"
.MoveNext
Loop
End With
'--------------------------------------------------
With oMail
.To = Left$(strEMail, Len(strEMail) - 1) 'Remove Trailing ;
.Body = "Please review the attached ECN and complete any and all tasks that pertain to you."
.Subject = Replace(Replace("ECN# |1: |2", "|1", Nz([ECN#], "")), "|2", Nz([NewPN], ""))
.Display
.Attachments.Add
End With
Set oMail = Nothing
Set oOutlook = Nothing
rstEMail.Close
Set rstEMail = Nothing
End Sub
This is what I have so far, the ".Attachment.ad d" is where I'm stuck. I want it to send a report that I have, based of the data in the form where this button is located, by the ID #.
I have tried it with out the .Attachment part and it does everything its supposed to, now I just need to get it to pull the report filtered based off of ID# on the Form.
Does anyone have any Ideas? I have done some searching and everything says to export the report first then attach it, which I prefer not to do.
Thanks for all the help.
Comment