Export report in PDF format and send it to email through outlook (1 Viewer)

comep

Registered User.
Local time
Today, 12:15
Joined
Mar 4, 2017
Messages
20
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
 

Ranman256

Well-known member
Local time
Today, 15:15
Joined
Apr 9, 2015
Messages
4,339
DoCmd.SendObject acSendReport, "rMyReport", acFormatPDF, "name@aol.com", , , "Subject", "message"
 

comep

Registered User.
Local time
Today, 12:15
Joined
Mar 4, 2017
Messages
20
I am using Visual Basic 6 so how can use this code on it ?
 

rwm75

New member
Local time
Today, 19:15
Joined
Dec 29, 2015
Messages
6
Hi m8,

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

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
 

Users who are viewing this thread

Top Bottom