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

Emailing From Access 2000

Status
Not open for further replies.

Tootle

Programmer
Sep 25, 2002
21
GB
Ok here is my problem

I have a form with a list box on with "Name" & "Email Address" behind the list box when i double click the name up comes a report that is to be sent to that person but i would like the report to be generated attached to an email and sent automatically.

I Have used sendobject and got as far as creating the email with the report attached as a snapshot but i cant get the email address to be pulled through i have the eamil address behind the listbox on the main form and also in a text box on the report itself. Any help would be appreciated as this is driving me insane.

Basically i need to be able to fill in the email address with the email address behind my list box all at the same time from clicking a button

Thanks in advance

Andy
 
Try something along the lines of....

---
Dim olapp As New Outlook.Application
Dim olMail As Outlook.MailItem
Set olMail = olapp.CreateItem(olMailItem)

olMail.Subject = "Subject Here"
olMail.To = "Name@Company.com"
olMail.Body = "This is a test Email"
---

You will have to add the attatchment yourself i believe, olMail.attatchments is what you are looking for, but you need to specify the objects to attatch and i dont know off the top of my head how to attatch an access report.

Read the manual on the topic, and have fun ;-)
 
Its ok i have achieved the goal by referencing back to the list box me.email
DoCmd.SendObject acReport, "ReportName", "SnapshotFormat(*.snp)", Me.Email, "", "", "Email Header", "Email Message", True, ""

This opens my outlook and sends the email automatically but if i cancel i get runtime error '2293'
which i now need to work around

Thanks

Andy
 
On Error Resume Next

Put that in the sub that runs the code, it should supress the error.
 
Thanks Fubear

Just what i needed

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top