Does anyone know how to:
Send active info from an open form (report references fields from open form) to a pdf document (which would get the document name from form fields) that would in turn open Outlook and have the pdf as an attachment.
I already have the mdb setup to open reports as pdf's.
Best regards,
Brent
4 2159
Does anyone know how to:
Send active info from an open form (report references fields from open form) to a pdf document (which would get the document name from form fields) that would in turn open Outlook and have the pdf as an attachment.
I already have the mdb setup to open reports as pdf's.
Best regards,
Brent
Sorry Brent but your question is confusing. Prehaps if you posted the code you are using to open the reports as pdfs it would help. Are you then trying to email these reports as attachments?
I am using the following code along with Lebans print to pdf code: - Private Function CurrentDBDir() As String
-
'Code courtesy of Terry Kreft & Ken Getz
-
-
Dim strDBPath As String, strDBFile As String
-
-
strDBPath = CurrentDb.Name
-
strDBFile = Dir(strDBPath)
-
CurrentDBDir = Left$(strDBPath, Len(strDBPath) - Len(strDBFile))
-
-
End Function
-
-
Private Function GetUniqueFilename(Optional path As String = "", _
-
Optional Prefix As String = "", _
-
Optional UseExtension As String = "") _
-
As String
-
-
' originally Posted by Terry Kreft to: comp.Databases.ms -Access
-
' Subject: Re: Creating Unique filename ??? (Dev code)
-
' Date: 01/15/2000
-
' Author: Terry Kreft <terry.kreft@mps.co.uk>
-
' SL Note: Input strings must be NULL terminated.
-
-
Dim wUnique As Long
-
Dim lpTempFileName As String
-
Dim lngRet As Long
-
-
wUnique = 0
-
If path = "" Then path = CurDir
-
lpTempFileName = String(MaxPath, 0)
-
lngRet = GetTempFileName(path, Prefix, wUnique, lpTempFileName)
-
-
lpTempFileName = Left(lpTempFileName, InStr(lpTempFileName, Chr(0)) - 1)
-
Call Kill(lpTempFileName)
-
If Len(UseExtension) > 0 Then
-
lpTempFileName = Left(lpTempFileName, Len(lpTempFileName) - 3) & UseExtension
-
End If
-
GetUniqueFilename = lpTempFileName
-
-
End Function
-
-
Public Function SendMail(strRecipients As String, strSubject As String, strBody As String, vAttachments As String) As String
-
-
'Written by Tom Wickerath, May 7, 2006.
-
'Entry (strRecipients) = Semicolon delimited string of recipients.
-
' (strSubject) = Required. Message subject.
-
' (strBody) = Optional. Body of the message.
-
' (vAttachments) = List of files to attach to e-mail (separated by commas)
-
-
Dim myObject As Object, myItem As Object
-
Dim vCount As Long
-
Dim vArray() As String
-
-
On Error GoTo ProcError
-
-
Set myObject = CreateObject("Outlook.Application")
-
Set myItem = myObject.CreateItem(0)
-
-
vArray = Split(vAttachments, ",") 'fetch attached filenames into vArray
-
-
With myItem
-
.Subject = strSubject 'enter Subject text
-
.To = strRecipients
-
-
If Len(Trim(strBody)) > 0 Then 'enter message text
-
.Body = strBody
-
End If
-
-
For vCount = 0 To UBound(vArray) 'scan array
-
.Attachments.Add (vArray(vCount)) 'add attachments
-
Next
-
-
.Display
-
' .Send 'this option will do the same as .Display but NOT display e-Mail program
-
End With
-
-
ExitProc:
-
Set myItem = Nothing
-
Set myObject = Nothing
-
Exit Function
-
-
ProcError:
-
MsgBox "Error " & Err.Number & ": " & Err.Description, _
-
vbCritical, "Error in SendMail Function..."
-
SendMail = "A problem was encountered attempting to automate Outlook."
-
Resume ExitProc
-
Resume
-
-
End Function
-
-
Public Sub EMailAsPDF(vReport As String, vPDFName As String, vEMail As String, vSubject As String, vBody As String)
-
-
'Send Access report as a .pdf file to one (or more) e-mail addresses
-
'Entry (vReport) = Name of report
-
' (vPDFName) = Name used for PDF file excluding .pdf extension
-
' (vEMail) = E-Mail address
-
' (vSubject) = Subject string
-
' (vBody) = Body of E-Mail string
-
-
'To send a report attached to an e-mail use code like this in your forms :-
-
'
-
' EMailAsPDF "YourReportName", "Name of PDF file", "Recipients e-mail address", "Subject Line", "Main body of e-mail text"
-
'
-
'To send the report to more than one recipient add other e-mail addresses separated by semi-colons. i.e. "Joe@aol.com;Fred@tiscali.co.uk"
-
-
-
Dim vFolder As String, vDBPath As String, vDBFile As String
-
Dim vDummy As Variant
-
-
On Error GoTo ErrorCode
-
-
vDBPath = CurrentDb.Name 'fetch name of db folder
-
vDBFile = Dir(vDBPath) 'extract filename
-
vFolder = Left$(vDBPath, Len(vDBPath) - Len(vDBFile)) 'fetch db folder name
-
vDummy = ConvertReportToPDF(vReport, vFolder & vPDFName & ".pdf") 'save Report to temp file as .PDF file
-
vDummy = SendMail(vEMail, vSubject, vBody, vFolder & vPDFName & ".pdf") 'send e-mail (with .PDF file attached)
-
Kill vFolder & vPDFName & ".pdf" 'delete temp file
-
Exit Sub
-
-
ErrorCode:
-
If Err = 2501 Or Err = 2465 Then Exit Sub 'if user cancels e-mail then abort
-
Beep
-
MsgBox "Error Code " & Err & ": " & Error 'else show error
-
-
End Sub
-
-
-
The code is used along with a command button with the following code:
-
-
event procedure: on click
-
-
Private Sub Open_BOL_Click()
-
EMailAsPDF "BOL", "Customer", "info@katybuys.com", "IMO", "Test"
-
End Sub
-
Instead of using hard coded customer name, email address, etc., I would like to use fields from my form to fill in the customer name, email address, document name and subject.
Thanks,
Brent
Hi Brent
Will this work for you ?
SendMail(Me!EmailControl, Me!SubjectControl, Me!BodyControl, Me!DocumentPath)
Substitute each control name with the name of the control on your form.
I used the following and it worked:
EMailAsPDF "IMO 1", Me.Title & Me.Dash & Me.po1 & Me.po, "email address here", Me.Title & Me.Dash & Me.po1 & Me.po, Me.Assigned_To.Column(1)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: MLH |
last post by:
I want to send 2 reports using SendObject.
Something like this would do nicely...
DoCmd SendObject A_REPORT, "rpt1";"rpt2", A_FORMATRTF, MyRecip, , ,
MySubject, MyBodyText, 0
....except for...
|
by: Ty Smith via AccessMonster.com |
last post by:
I noticed that the week numbers in Stephan Leban's MonthCalendar are not consistent with Microsoft Outlook (they are shifted one week forward). Is there any way I can sync these two up by changing...
|
by: Sean |
last post by:
Hi... I want to use the macro/sendobject (or any other
procedure) to send the contents of a table (very small, ~5
rows/columns) as an Outlook message body, not as an
attachment. Access 2000 will...
|
by: vtashore |
last post by:
I downloaded Steve Leban's RTF2 control and it works as advertised.
Good news!
After reading reference material on the RTF standard codes, I have been
able to write update queries to universally...
|
by: =?Utf-8?B?SHVnaA==?= |
last post by:
Hi There,
I use follow code to send email inside VB.NET 2005. It does not work well.
Error message of "Failure sending email" would occue. However, email was
sent out sometimes. I am confused...
|
by: Pascal Hagedorn |
last post by:
I downloaded Steve Leban's RTF2 control and it shows me the report as
wanted.
The Problem is, if i want to print it, it comes a PopUp where it says
"properties write protected" (german:...
|
by: Tom |
last post by:
Hi all:
I'm having an odd problem with Stephen Leban's PDF creator. I'm
trying to output to 11x17 sized paper. The PDF creator does its thing
and when the PDF file opens, its at 800% zoom and...
|
by: JessicaZ |
last post by:
Hi everyone! I'm new here and have a question regarding Leban's report to pdf tool. I am working on a database where we are using this code to send a report out to pdf(duh) BUT what I need to do is...
|
by: deepaks85 |
last post by:
Dear All,
I want to send some data through a form with Multiple attachment in an HTML Format. I have tried it but it is not working for me. I am able to send data without attachment but with the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |