Print to PDF and Attach to E-mail with one command button

  • Thread starter Thread starter Jonathan via AccessMonster.com
  • Start date Start date
J

Jonathan via AccessMonster.com

I am trying to create a PDF of the current record of a form and have it
attached to an e-mail with the click of one button. Currently, the user has
to manually attach the PDF to an e-mail after they save it.
Any help would be greatly appreciated.
 
Jonathan via AccessMonster.com said:
I am trying to create a PDF of the current record of a form and have it
attached to an e-mail with the click of one button. Currently, the user has
to manually attach the PDF to an e-mail after they save it.
Any help would be greatly appreciated.

Write the PDF file to some temporary location and call the function below
assuming you want to use Outlook. Delete the temp file after.

Public Sub MailIt(strContactName As String, strFile As String)
Dim objOutLook As Outlook.Application
Dim objMail As Outlook.MailItem
Dim objContact As Outlook.Recipient

Set objOutLook = New Outlook.Application
Set objMail = objOutLook.CreateItem(olMailItem)

With objMail
.To = strContactName
.Subject = "RE: some subject line"
.Attachments.Add (strFile)
.Display
End With

Set objMail = Nothing
Set objOutLook = Nothing
End Sub
 
Jonathan via AccessMonster.com said:
I am trying to create a PDF of the current record of a form and have it
attached to an e-mail with the click of one button. Currently, the user has
to manually attach the PDF to an e-mail after they save it.

I use Steve Arbaugh's Mail and PDF class, in conjunction with Win2PDF. The
class works with most popular PDF creators, but I've found that Win2PDF is
so much faster and more trouble-free than either the free ones, or
especially Adobe Acrobat that I wouldn't dream of using anything else. This
isn't a free solution, but it is a smooth one. My code creates a PO report,
then makes a PDF and gathers several other PDFs and merges them into the one
I created, creating a new PDF, then it finds the email address and and sends
the PO as an attachment by email.

Here are the pertinant programs:

Mail and PDF Class:
http://ourworld.compuserve.com/homepages/attac-cg/

Win2PDF:
http://www.win2pdf.com/
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Back
Top