Email Attachment File Name

I did this and it produced the message "No Record"
 
Did you look? Was the fiel there? Hmm, might be grabbing faster then it's outputting. Do AFTER the DoCmd.OutPutTo but BEFORE the DoCmd.SendObject put...

DoEvents
 
Explain do events; is it captured during the initial click of command button and the call to do events gives it time to catch up or, set up two separate command buttons? Latter is not preferred.
 
DoEvents < One word... It allows the report to go out to the harddrive prior to it trying to attach to eMail. The message you indicated you got inidicated the file was not there yet to be attached to eMail. This will give it that time, so once it is done the code will continue along and attach to eMail.

That is also wy I was specific about the placement. Oh, and no, it is not captured on the initial click only when it gets to that line.
 
I did as you suggested and still I received the message "No Current Record"
What I discovered, I believe, is the Docmd.SendObject will only send the current record of the Form, Module, Report, Table, Query or NoObject based on your acSend "Selection" and the ObjectName must be specified as one the selections in the current db.
What I believe is if you put any other ObjectName in this slot, Access determines that this is not an object in the database and therefore there is no record to send. I tested this by manipulating the ObjectName several ways, even with a .pdf file
I verified the file exists with correct path as well as manipulating the report name within the VBA code of this button. You either get a message “ No Current Record” or “Invalid Use”

I took some time to examine the DoCmd.SendObject method and the code I have written. Most of it is working.
1. It sends the [ObjectType] type of object selected (acSendReport)
2. It sends the [ObjectName] (“Estimate”) - (whether open or not, just be sure to have filters)
3. It doesn’t do The [OutputFormat] as selected (acFormatPDF), it does it in .dat
Note: First time I sent object I had to use the open with selection in order to change what program would be used to open the file. (.dat files are now opened with Adobe)
I sent the Report to an associate in an email from Access using this code:
DoCmd.SendObject acSendReport, "Estimate", acFormatPDF, strToEmailAddress, strCcEmailAddress, strLastName & strTitle & strNumber & strEstDate, "Your BHR Copy of the Estimate is attached", True, False
The recipient received the Attachment as a .dat file and could not open it
4. It does correctly send [To] (strToEmailAddress)
5. It does correctly send [Cc] (strCcEmailAddress)
6. It does correctly send[Subject] (strLastName & strTitle & strNumber & strEstDate)
7. It does correctly send [MessageText] ("Your BHR Copy of the Estimate is attached")
8. It does Allow [EditMessage] = (True)
9. Not sure about [TemplateFile] = I’ve read the description of its purpose in VBA and Macro and always come back to “Only Applies to HTML”. I am not very savvy when it comes to understanding what one thing has to do with another. I can only guess this is not required because I am not sending an HTML. What I would like to confirm is that I definitely do not need to worry about a [TemplateFile] when sending the Report as a PDF Email Attachment or in some strange way it is required in order to convert the .dat file into .pdf. However, I have not found, read or been directed to anyhthing referrencing this [TemplateFile] that I undrestand.

Tests I have done and believe to be relevant:

1. DoCmd.OutputTo acOutputReport, "Estimate", acFormatPDF, [OutputFile] does send the Report to the OutputFile in .pdf format. Clearly see icon and when you click on it (in the files folder) it opens in .pdf with the FileName.pdf as you would expect.
2. DoCmd.SendObject acSendReport, "Estimate", acFormatPDF, strToEmailAddress, strCcEmailAddress, strLastName & strTitle & strNumber & strEstDate, "Your BHR Copy of the Estimate is attached", True, False sends attachment as (The Icon is not PDF) {“Collection of Numbers and Letters”}.dat to my email. Because my email has now been programmed to open .dat files in Adobe it opens in pdf; this condition may only apply to someone who has the option that prompts “Open With” and who then selects to open with the Adobe. If you don’t have a program (or knowhow to use open with) you are directed to the internet to find program that will open it.
3. I then changed the [To] (strToEmailAddress) to other associates who have verified it is being received as a .dat file and they can’t open it. (maybe they could if they knew to use open with) and that is one of main concerns I have.
4. To further test my theory and try to isolate the problem, I used the email icon in the Access External Data Ribbon which produced the same result as the code; the attachment was not .pdf it was still .dat.

My conclusion by evaluating the tests of I have done, is as follows:

Access is not outputting data to email in .pdf format even after format is requested. However, it will to a file on the computer.

Is there something I am missing in data base settings?
 
WOW, you have been busy!

I know that it works because I use it and the report is not open. I send Access reports as .PDF's all the time. What I don't do is send them out to a file in a directory, no need because it is using the Access report and I have never had one attach as a .DAT file.

Here's what I use...

Code:
DoCmd.SendObject acSendReport, "rptCoD", acFormatPDF, vRecipientList, , , vSubject, vMsg, False

...this is why I am confused as to why it is not that simple for you. If you can open the report you should be able to eMail it. Is there any way you can upload a stripped down version so I can have a look?
 
Can you define stripped down version?
Do you mean the data base "dummy copy"? lol
 
I am getting a creepy feeling it is an msn setting or Access output setting I can't find. Perhaps if you could use my data base in your environment we could narrow it down to these issues.
 
Stripped down mean rmove all sensitive information... Yes, I want the copy to try in my environment AND I have several environments to try in!
 
I have created a small data base that allows the report to function called "Dummy Data Base". This is going to sound dumb, no pun intended, but how do I get it to you. I don't see an option to attach it here in this forum. I am a newbie
 
Instead of posting a Quick Reply... Go Advanced and look for the Paper Clip, next to the Happy Face, click and follow directions...
 
Yes, I got it but there is no form with button or code. I want to make what you have work.
 
The Report has the button called "Email". Open report in report view.
 
Well, this works fine with Outlook and Windows Live Mail. So do you have one of those set up and do you have an eMail set up to receive in one of those?
 
I went to our main computor and created the same "DummyDataBase" there. Whata difference. However, it went to windows live for email and not msn. I did open my msn and I was able to viewthe email there as well; sent it to myself.
Email Attachment: "Estimate.pdf", Awesome.

However, what is wrong at the other computor. Access or email. My Access at the main computor auto opened Windows Live. The Laptop opens msn. Any ideas?
Microsoft owns them all, you think they would make all work better together?!?
 
It will not go to MSN on the Internet, that will never happen but it will go thru MSN if you set it up in Windows Live Mail. It may open it but it can't do the file attachment thingy (professional word).

You need to use an MAPI compliant eMail program... that would be Outlook or Windows Live Mail. They do play nice, set it up in Windows Live Mail. Now, once you have that working I will help you get customized names... that would be tomorrow, it's midnight here so off to sleepy land I go!
 
Thank You so much. Isn't it funny that there really wasn’t a problem at all with the Access software? I do think Microsoft could have made this information available when they created the "indispensable" email options. It’s such an easy thing to underline or put in bold; they had to know. I was held in limbo for days, including all your time vested. I wonder how may would have given up?
I would appreciate the ability to customize the file name; perhaps this where renaming the Report.Caption comes into play; I never followed through on this after encountering the msn glitch. I am pretty sure I can handle the manipulation of subject, to whom, etc… Will need help with the file name.

Again, Thank You for Your Help and Guidance
 
I guess you could say they do kinda make it known by saying MAPI compliant software. That is really meant to mean *No Internet*, in typical *computerese*... :rolleyes:

Okay, to give your file a custom name you would fist have to save it somewhere so we can attached the saved copy to eMail. I got a little side tracked and don't remember, was that part working? Does the file save outside that database as a .PDF?
 
Yes, I send it to a file Called
BHRIR-AccessEmailEstimateAttachments.
I consider this a temp file to store each file by its unique Title.
I.e. "WalkowiczEstimate25229-082012BHRCopy.pdf"
[LastName]&"Estimate"&[EID]&"-"[EstimateDate]&"BHRCopy"
The PDF being added by the Output Method.
 

Users who are viewing this thread

Back
Top Bottom