Sending a form & reports by e-mail (1 Viewer)

ptaylor-west

Registered User.
Local time
Today, 11:37
Joined
Aug 4, 2000
Messages
193
I have an input form which creates a quotation and normally I just print it off, I now want to be able to e-mail it, bearing in mind only the current record needs to be sent. I have tried expoorting it as a text, excel & RTF file but it comes out as columnar and nothing like what the form looks like. The only solution I have come up with is to print it to a PDF Writer which works fine, but is there an easier way as this is complicated for an operator to do - a command button would be ideal. Also my next problem is a simple way of accessing the e-mail address from the access database so that I can send the form - can this be automated, because at the moment I go into Outlook and raise a new message and send a file as an attachment, which is very antiquated I really need to be able to send any form or report direct from within the database as you can within a Word or Excel document.
 

charityg

Registered User.
Local time
Today, 11:37
Joined
Apr 17, 2001
Messages
634
The first thing you need to do is make sure the email address appears on the form, and that each record has a primaryKey which matches the key on the report. Modify your report so that it is based on a query. In the primarykey criteria field enter the form's primarykey field. Forms!frmName!fldName

This will assure that the report only opens the current record.

In the onClick event of the command button use:

dim strEmail as string
dim strDoc as string
Dim strSubject as string
Dim strMessage as string


strEmail=forms!frmName!fldEmail
strDoc="rptName"
strSubject="This is the subject of the email"
strMessage="This is the message that will be included in your email."

DoCmd.SendObject acSendReport, strdoc,acFormatRTF , strEmail , , ,strSubject , strMessage, False

Using false in the edit parameter allows this to be completely automated. If you want to allow changes to the message before sending then change this to true.

If your report has alot of line formatting or graphics, using RTF will remove this formatting. I installed snapshot viewer to maintain all formatting and I send a link to Microsoft's download sight so that the end user can install it to view the report.

Like this

strMessage="My message" & Chr(13) & "To view this document you must install SnapShot Viewer which can be downloaded from:" & Chr(13) & Chr(13) & "http://www.microsoft.com/accessdev/prodinfo/snapdl.htm"

DoCmd.SendObject acSendReport, strdocname, "SnapShot Format", , , , , strMessage, False


HTH
Charity

[This message has been edited by charityg (edited 06-12-2001).]
 

ptaylor-west

Registered User.
Local time
Today, 11:37
Joined
Aug 4, 2000
Messages
193
Thanks for pointing me in the right direction, you have put a lot in there which I will need time to get my head around, but I'm still not sure about using Snapshot to view the formatting as there are a lot of lines for sub-totals and calculations for working out taxes & I know RTF doesn't interpret them very well - it may be that the PDF way might be ther solution as everyone has the Acrobat reader, or I can use your code to prompt to download. But your info and help is greatly appreciated. Many thanks
 

Users who are viewing this thread

Top Bottom