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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attach access report in Access to a body of an email

Status
Not open for further replies.

marcin2k

Programmer
Jan 26, 2005
62
CA
Is there any way of attaching a report to a body of my email. Here is my code so far:

Dim dbs As DAO.Database
Dim rst As DAO.Recordset

Dim OutlookApp As Outlook.Application
Dim OutlookMessage As Outlook.MailItem

Set dbs = OpenDatabase("C:\a\EmailSend.mdb")
Set rst = dbs.OpenRecordset("Select * From tUsers Where tUsers.ID = " & [Forms]![fSend]![txtID], dbOpenDynaset)

Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMessage = OutlookApp.CreateItem(olMailItem)

Dim EmailSubject As String
Dim EmailMessage As String

EmailSubject = "Weekly Update"
EmailMessage = "I want to attach the report here"

OutlookMessage.Body = EmailMessage
OutlookMessage.Subject = EmailSubject
OutlookMessage.To = rst!Email
OutlookMessage.CC = ""

OutlookMessage.Send

rst.Close
dbs.Close
 
Why not using the DoCmd.SendObject method ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I acctually made two applications one using the DoCmd. which works perfect but now I want to show my boss another way of doing it by using the OutlookMessage. way. Thats why I was asking if its possible to add the report to the body.
 
Try using the
OutlookMessage.Attachments.Add "this would be the location of the attachment, like C:\SomeReport.RTF"
before your OutlookMessage.Send

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top