Go Back   Access World Forums > Apps and Windows > Visual Basic

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 09-08-2017, 12:55 AM   #1
comep
Newly Registered User
 
Join Date: Mar 2017
Posts: 20
Thanks: 1
Thanked 0 Times in 0 Posts
comep is on a distinguished road
Export report in PDF format and send it to email through outlook

Dears

Hope you are doing well .

I search through internet to find a solution to extract data report in PDF format in first stage and then send it to email using outlook but i did not found a clear solution for this so if there anyone can help me on this i will appreciate that .

I don'h have a code to share it with you .

Thanks in advance

comep is offline   Reply With Quote
Old 09-08-2017, 01:26 AM   #2
Ranman256
Newly Registered User
 
Join Date: Apr 2015
Location: KY,USA
Posts: 2,509
Thanks: 0
Thanked 538 Times in 524 Posts
Ranman256 will become famous soon enough
Re: Export report in PDF format and send it to email through outlook

DoCmd.SendObject acSendReport, "rMyReport", acFormatPDF, "name@aol.com", , , "Subject", "message"
Ranman256 is offline   Reply With Quote
Old 09-08-2017, 02:19 AM   #3
comep
Newly Registered User
 
Join Date: Mar 2017
Posts: 20
Thanks: 1
Thanked 0 Times in 0 Posts
comep is on a distinguished road
Re: Export report in PDF format and send it to email through outlook

I am using Visual Basic 6 so how can use this code on it ?

comep is offline   Reply With Quote
Old 10-04-2017, 04:57 AM   #4
rwm75
Newly Registered User
 
Join Date: Dec 2015
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
rwm75 is on a distinguished road
Re: Export report in PDF format and send it to email through outlook

Hi m8,

I had the same question and managed to get the code below to work. If it helps, crack on buddy

Private Sub cmdEmail_Click()

Dim olLook As Object 'Start MS Outlook
Dim olNewEmail As Object 'New email in Outlook
Dim strContactEmail As String 'Contact email address
Dim strEmailSubject As String
Dim strPath As String
Dim appword As Word.Application
Dim Doc As Word.Document
Dim Path As String
Dim DocName1 As String
Dim DocName2 As String
Dim DocName As String


On Error Resume Next
Error.Clear

Path = "Where to save the file"

DocName1 = Me.txtIncCat.Value
DocName2 = Me.txtIncNature
DocName = DocName1 & " " & DocName2

DoCmd.RunCommand acCmdSaveRecord

DoCmd.OpenReport "rptSecurity Incident Report", acViewPreview, "", "[tblSECURITY INCIDENT REPORT]![DOL]=[Forms]![frmSECURITY INCIDENT REPORT]![txtDOL]", acNormal

myPath = "Where to save the file" & (DocName) + ".pdf"

DoCmd.OutputTo acOutputReport, "", acFormatPDF, myPath + strReportName, True
DoCmd.Close acReport, "rptsecurity incident report", acSaveNo

Call JoinStrings

Set olLook = CreateObject("Outlook.Application")
Set olNewEmail = olLook.CreateItem(0)
strEmailSubject = ""
strEmailText = " Kind Regards"
strPath = "Where to save the file " & (DocName) + ".pdf"
strContactEmail = Me.cboEmail.Column(2)

With olNewEmail
.Attachments.Add strPath
.To = strContactEmail
'.CC = strCc
.Subject = eMailSubject
.Body = strEmailText
.Display
End With

End Sub

rwm75 is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Send Access report in body of Outlook email bwc Reports 0 03-27-2014 06:13 AM
Send a specific email from outlook to all email addresses within a quiery Ads General 6 01-22-2014 06:42 AM
How can I send an email to multiple email addresses through Outlook 2007 farisallil Forms 2 07-26-2009 07:54 PM
Help Send Email via Outlook to populate FROM email wiselittlemonkeys Modules & VBA 1 04-10-2008 11:05 AM
Send Outlook email w/ Report Attachment only to names on the report JPritch General 0 12-02-2005 12:20 PM




All times are GMT -8. The time now is 08:54 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World