Francis:
What Steve suggests will work fine for most cases. My application required
me to export (transfertext) a fixed-width text file & then email it. I
setup a macro which opens a form that includes my VBA code in the open
event. The last item I coded was "docmd.quit" (which will close the db).
If you are planning on using a VBA procedure, use the following code:
Use the code below from Arvin Meyer to send the attachment.
Private Sub Command0_Click()
'Arvin Meyer 03/12/1999
'Updated 7/21/2001
On Error GoTo Error_Handler
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
.To = "(e-mail address removed)"
.Subject = "Look at this sample attachment"
.body = "The body doesn't matter, just the attachment"
.Attachments.Add "C:\Test.htm"
'.attachments.Add "c:\Path\to\the\next\file.txt"
.Send
'.ReadReceiptRequested
End With
The security dialogs that pop up when an application tries to access Outlook
designed to inhibit the spread of viruses. Try this freeware to auto click
the Yes (
http://www.express-soft.com/mailmate/clickyes.html)
One item to watch for - make sure you have "Microsoft Outlook" checked as
one of your references.
Hope this helps!
Craig Schmuck