Email Attachment File Name

BHRIR

Registered User.
Local time
Yesterday, 16:23
Joined
Aug 26, 2012
Messages
33
First and Foremost, 1st time and 1st post

I am a business owner with a wife who loves to help out.
I want to make it easier for her to send a report via email in PDF format.

I've been able to do this and the Email Attachment is a PDf.

The Problem Is!
The Email Attachment makes no sense to those who receive it
Example: {A group of numbers and letters}
What we want: OurFileName.PDF

Any Help Would Be Greatly Appreciated, I have spent 2 days in forum looking for similar problems with no luck

New User Stumped
 
DoCmd.SendObject acSendReport, "Estimate", acFormatPDF, strToEmailAddress, , , _
"Issues Report", "Issues Report is attached", True
 
Try changing True to False... they will not be editing anything.
 
Changed TRUE to False

Attachment File Name as it appears in email attachment box

{F54EBDF9-B9B6-4EA1-B56D35DEC50D0F69}.dat (257KB)

When you select open
it does retreive the file in PDF
However, our customers are not very likely to open it because of its File Name.

I do send the document to PDF file 1st
Please keep in mind, that I am a carpenter by trade just trying to make my business more easier to run from the office and keeping up with the times.

I receive emails from Vendors all the time, I open them because the description of the attachment makes sense.

I am an avid user of Access since 2000, I barely understand VBA code and often copy from samples and/or researched code.

Here is my Code:
Private Sub Command198_Click()
Dim strToEmailAddress As String
Dim PDF_Name As String
strToEmailAddress = Me!CCEmail
PDF_Name = "C:\Users\BHRIR Laptop\Documents\BHRIR\BHRIR-AccessEmails\" & "Estimate" & ".pdf"
DoCmd.OutputTo acOutputReport, "EstimateBHRPrint1", acFormatPDF, PDF_Name
DoCmd.SendObject acSendReport, "EstimateBHRPrint1", acFormatPDF, strToEmailAddress, , , _
"Issues Report", "Issues Report is attached", False
End Sub
:banghead:
 
It is not grabbing the one off your Harddrive. It is grabbing EstemateBHRPrint1, so Part 1 is it is confused and so am I as that is not what you sent the firt time I asked.

1. Is EstimateBHRPrint1 a real report?
2. What version of Access?
3. Do you want the attachment to be named Estimate.pdf?
 
1. EstimateBHRPrint1 is the real report
(This is the report that is open in report view when I click the commend198 to run VBA code)
2. I currently use Access 2010 (System displays 2007-2010)
3. I would love to have the Attachment Named "Estimate" & "EstimateID" & "LastName". I have tried some code I found trying to change the Report Caption, currently named "Estimate"

I should add, I am not using outlook, just .msn email. I do not want to have to look into using Outlook right now. Just want Attachment File name to read as stored file name instead of a bunch of numbers.dat
P.S. I've managed somehow to remove the .dat in Attachment box and display PDF File logo, that I did with the open selection open with - make selection

Thanks so much for working with me, I hope you are better at this than I am, lol
 
Okay... then you have the report with the name Estimate, that would step one. Second is the lastName and the EstimateID on the form you are sending the report from?
 
Yes,
The Report Caption is Estimate but I also have a Field on the Report called [Title]. In the Reports Query named EstimateReport, [Title] is set to equal "Estimate"
The Report also has Field Names [LastName] & [EID] (The Estimate Number)
 
The report *name* must be Estimate, not the caption but the name. On the form that you send the report from must have the fields EstimateID and LastNme not on (or in) the report or the query. Well, you can them there also but they must be on the form from which you send the report.
 
I am sending from a report in report view and not a form. However, I can change this if that is this reason why it is not working.
 
I know that... okay, let's do this... how do you send the report? Do you press a button on a form?
 
Changed it so that I would have the command and VBA code on a form that has all the same fields as the report I was using. Still the email attachment is listed as {Numbers}.dat. Don't know what I am doing wrong. If there is code I can use to manipulate the Attachment File Name, this would be great.
 
Yes, the button (Command) is on the report and now on a form.
It is named EmailEstimate.
Here is its VBA code on Click()

Private Sub EmailEstimate_Click()
On Error GoTo EmailEstimate_Click_Err
Dim strToEmailAddress As String
Dim strCcEmailAddress As String
Dim strLastName As String
Dim strTitle As String
Dim strNumber As String
Dim strEstDate As String
Dim strFileType As String
Dim PDF_Name As String
strToEmailAddress = Me!EmailAddress & ";" & Me!BCEmail
strCcEmailAddress = Me!CCEmail
strLastName = Me!LastName
strTitle = Me!Title
strNumber = Me!EID
strEstDate = Format(Me!EstimateDate, "-MMDDYY")
strFileType = ".PDF"
'PDF_Name = "C:\Users\BHRIR Laptop\Documents\BHRIR\BHRIR-AccessEmails\" & Me!LastName & Me!Title & Me!EID & Format(Me!EstimateDate, "-MMDDYY") & ".pdf"
PDF_Name = "C:\Users\BHRIR Laptop\Documents\BHRIR\BHRIR-AccessEmails\" & Me!LastName & Me!Title & Me!EID & Format(Me!EstimateDate, "-MMDDYY") & ".pdf"
DoCmd.OutputTo acOutputReport, "EstimateBHRPrint1", acFormatPDF, PDF_Name
DoCmd.SendObject acSendReport, "Estimate", acFormatPDF, strToEmailAddress, , , _
strLastName & strTitle & strNumber & strEstDate, "Your Estimate is attached", False

EmailEstimate_Click_Exit:
Exit Sub
EmailEstimate_Click_Err:
MsgBox Error$
Resume EmailEstimate_Click_Exit
End Sub

I have been updating during our session, but don't believe it has changed/affected the result.
 
Everything works fine except the Email Attachment File Name.
I'm Stumped, it seems to be a fairly simple process.

FYI:
I did this with a macro as well using EmailDatabaseOblect and still everything works fine; again except for the email file name which produces the same result as VBA code {Bunch of Nuimbers and Letters}.dat
 
Because you are eMailing the report in the database not the one saved to your harddrive which is why the one in the database must have the same name as the one you are eMailing. Is that making sense to you? By your replies i'm thinking you are misunderstanding what I am saying...
 
Last edited:
I do realize what you are saying to some degree. This is what I am hearing; because I am attaching the report through Access 2010, I am allowing Access to name the file which was originally data; hence the batch of numbers and letters followed by .dat.
That being said, I believe I have seen different VBA code in the furom and elsewhere indicating you can and trap/identify/clone this record in VBA code and reassign it a new name before attaching it to an email.
 
Hmmm, good thing you told what you are hearing because that tells me I am not expalining correctly.

The report name in Access *NameOfReportInAccess* must be the same name as the one indicated in the DoCmd.SendObject line. Access is not naming the file BUT yes, you can *change* the name, kinda... When attaching to eMail you can *expand* on the name but it MUST include the name of the report.

As a side note, if you where just sending to your harddrive then you could change it AND if you include the entire path grab THAT file and attach to eMail.

Hope that came out better...
 
I did verify that the *NameOfReportInAccess* is the same as the one called in the DoCmd.SendObject line. In both, from the Form (In Form View) and from the Report (In Report View), the Name of the Report is the same as the DoCmd.SendObject line. The only verification for the *NameOfReportInAccess* is its name list from the Report Selection Listing in the db.
Everything works except for the Attachment File Name. What a hassle. I can't offer any reason why there is still this issue. It should, at least indicate the filename as "Estimate", but would like to expand the FileName. This would give it the reference it requires in communication. I’ve sort of addresses the issue in the subject line, but still need to have the file at least indicate “Estimate”
If there is a way to email the PDF on our hard drive, while in access in an automated step, this would work. The reason for the output code is to store a copy on the hard dive. We currently email attachments by locating this file on the hard drive manually. This is something I have gotten used to, but find it the long way to do it. The problem is for the individual less Access savvy and not familiar with locating folders and attaching documents.
We started using email to get our estimates to clients faster and more accessible/portable. Using this method in Access in indispensable and leaves less room for error (Someone getting someone else’s estimate).

Resolving the issue with the Attachment File Name will allow the sender to check their work for accuracy. As I had indicated earlier, I receive email from vendors with PDF and other attachments, I open them because it may “Quote”, “Order”, “Invoice”, etc… with the documents ID. I’d like to think I can offer the same courtesy to my clients.

Thanks for all your help, I hope you can assist me further perhaps someone can jump in and offer suggestions.
 
Let's try this, instead of the Report, which is not working, put the path and name of the .PDF where the report is. So, instead of *Estimate* put, ie...

"C:\FolderName\NameOfFile.pdf"

...the complete path of the one you saved.
 

Users who are viewing this thread

Back
Top Bottom