Creating a formatted document in an email from Microsoft Access

To create a formatted invoice, quotation, purchase order or such  to send as an email you will need to use VBA code to create a largish string. This string will then be passed to the SendObject command as the body of the email. We use vbCrLf as new line characters in the following sample. You can use the format function to create formatted numbers such as dollar amounts or dates.

You can also use Stephen Leban's HTML Editor to send HTML emails.  However you must ensure that your email sending program supports HTML formatted emails.  Which SendObject does not.

Me refers to the form on which this button which contains the following code will reside. I'm assuming that all this information is on this form even though it may be small and hidden.

strBody = me!cCustomerName & vbCrLf & _
    me!cCustomerAddress1 & vbcrlf & _
    "*** INVOICE *** Nbr: " & _
me!InvoiceNumber & _ vbCrLf & _

etc, etc. The above is just air code.

Also if you want to centre or right justify items within the body of this email you will need use the Len and space function to calculate and insert the necessary number of spaces.

For a complete set of sample code click here.

This will all be time consuming and mind numbing until you get the email spacing all figured out.

(Note to the old-timers - This reminds me somewhat of creating RPG reports but a lot more tedious compared to old modern drag, drop and stretch methods..)

For corrections or additional information email Tony Toews

[ Email | AccessMain ]