Email Report!

pgp

Registered User.
Local time
Today, 21:50
Joined
Jul 1, 2003
Messages
33
Hi,

I have a email button - on clicking of which I would like to open our default email client - MS Outlook with a report attached as a word document

Im using DoCmd.SendObject ....

Problems Im facing:

1. I want to use the to: email address from the textbox input in the form. How can I do this?

2. The report I'd created has 2 jpegs , but when it attaches as a word doc, both these jpegs are missing!! Why is this?

Thanks in advance for any ideas/input
 
1. I want to use the to: email address from the textbox input in the form. How can I do this?

Modify your SendObject statement to something like this:
Code:
Dim strEmail As String

' Use Me.YourTextbox name in place of the
' Me.txtEmailAdd in the following statement.

strEmail = Me.txtEmailAdd

DoCmd.SendObject , , , strEmail, _
        , , "Subject Line", , True
If you need to put multiple names in the SendTo you can use semi colons to seperate them or you can use a for next loop to cycle through a table of names. Here is a working sample for you:
Code:
Dim rsEmail As DAO.Recordset
Dim strEmail As String
Set rsEmail = CurrentDb.OpenRecordset("YourQuery")

Do While Not rsEmail.EOF
strEmail = rsEmail.Fields("EmailAddress").Value
DoCmd.SendObject , , , strEmail, , , "Subject",  _
"Message Text"

rsEmail.MoveNext

Loop
Set rsEmail = Nothing
Then make sure you change these to match the names in your table/query.

"YourQuery" = Table or Query Name.
"EmailAddress" = Field in Table or Query holding the email address.

This will loop through an entire table or query sending an email to everyone in it.
2. The report I'd created has 2 jpegs , but when it attaches as a word doc, both these jpegs are missing!! Why is this?
My guess is that there is a problem with image linking. The image path in the email is probably pointing to a location on your hard drive, which is not available to Outlook users. You may have to store the images on a web server and use HTML to glue em together. There may be an easier way to accomplish what you want but I have not run across it yet. Maybe someone else will offer some insight on this.
 

Users who are viewing this thread

Back
Top Bottom