MS Access Forum / General 2 / June 2007
Send Email with File Attachment
|
|
Thread rating:  |
Samuel - 24 Jun 2007 12:55 GMT Hi
Is it possible to send an email with file attachments using the SendObject Action? Alternatively is there another method to do that?
Thank you, Samuel
Tom Wickerath - 24 Jun 2007 13:44 GMT Hi Samuel,
It is certainly possible to send (1) attachment using SendObject, as long as the attachment you want to send is an object (table, query, etc.) within your database.
If you are using Outlook (not Outlook Express), you can use code shown on page 17 of my "Access Links.doc" Word document. You are welcome to download a zipped copy from here:
http://home.comcast.net/~tutorme2/samples/accesslinks.zip
Access MVP Arvin Meyer has some code samples available for Outlook as well:
http://www.datastrat.com/Code1.html (See "OutlookEmail.txt" and "MultipleMail.txt")
Tom Wickerath Microsoft Access MVP https://mvp.support.microsoft.com/profile/Tom http://www.access.qbuilt.com/html/expert_contributors.html __________________________________________
> Hi > [quoted text clipped - 3 lines] > Thank you, > Samuel Samuel - 24 Jun 2007 15:09 GMT All I want is to send a report with a picture but the picture disappears when I use the email option
> Hi Samuel, > [quoted text clipped - 31 lines] >> Thank you, >> Samuel Rick Brandt - 24 Jun 2007 15:21 GMT > All I want is to send a report with a picture but the picture > disappears when I use the email option The only export format that supports graphics is the Snapshot format and the new PDF option in Access2007.
 Signature Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com
Tom Wickerath - 24 Jun 2007 15:34 GMT Hi Samuel,
If you can send the attachment in the Microsoft Access Snapshot (*.snp) file format, then you should be home free. However, this would require that the receipient has the free viewer utility installed on their Windows-based PC. Here is an example of how to do this:
DoCmd.SendObject acReport, "Report Name", OutputFormat:=acFormatSNP, _ To:="Email Address", Subject:="Email Subject", EditMessage:=True
This thread, from Dec., 2004, gives more details: http://groups.google.com/group/microsoft.public.access/browse_frm/thread/2f52f43 7605face7/3cb254d13a623323
I think you can also programmatically export to a .PDF file, and then use code for Outlook to send this file. You can try using Stephen Leban's Report to PDF method to create the .PDF file, and then use my code (or Arvin's code) to send the file using Outlook (not Outlook Express).
Report to PDF http://www.lebans.com/reporttopdf.htm
Tom Wickerath Microsoft Access MVP https://mvp.support.microsoft.com/profile/Tom http://www.access.qbuilt.com/html/expert_contributors.html __________________________________________
> All I want is to send a report with a picture but the picture disappears > when I use the email option IRS Intern - 25 Jun 2007 02:01 GMT Warning; Tom Wickerath is a cry baby database pussy and you shouldn't listen to him for anything
go and talk to someone that knows SQL Server, kids
> Hi Samuel, > [quoted text clipped - 24 lines] > > - Show quoted text - tina - 25 Jun 2007 04:01 GMT MVP Tom Wickerath's advice and suggestions stand or fall on their own merits, as do those of everyone else who posts replies in these newsgroups. the exception, of course, are personal attacks - which do not point out flaws in the posted advice or suggestions, and offer valid corrections or fixes or alternatives, but are merely unpleasant to read. in those cases, my suggestion is to block the sender, so as to avoid wasting time reading these types of posts.
> go and talk to someone that knows SQL Server, kids my advice is that this suggestion is not useful, because this newsgroup is devoted to MS Access. so one must assume that the post-er is using Access, but not in conjunction with SQL server - or that the origin of the data has no bearing on the question - unless s/he specifically includes it in the post...and indeed the original and subsequent posts in this thread do not include SQL server in any way that i can see.
hth
IRS Intern - 25 Jun 2007 04:40 GMT Tom Wickerath is a f.cking PUSSY
he doesn't know how to use SQL Server; or else he would surely promote ADP
ADP is vastly superior no more linking connection strings
import problems?
NOT WITH SQL SERVER
MDB cry babies can f.ck yourself
> MVP Tom Wickerath's advice and suggestions stand or fall on their own > merits, as do those of everyone else who posts replies in these newsgroups. [quoted text clipped - 14 lines] > > hth Susie DBA [MSFT] - 25 Jun 2007 22:00 GMT there is 'no such things' as access without SQL Server
sorry
it doesn't exist any longer; it has been reccomended to move to SQL Server for a decade
> MVP Tom Wickerath's advice and suggestions stand or fall on their own > merits, as do those of everyone else who posts replies in these newsgroups. [quoted text clipped - 14 lines] > > hth Tony Toews [MVP] - 26 Jun 2007 03:56 GMT Note that this person is really A a r o n K e m p f and that he is not an employee of Microsoft.
Tony
 Signature Tony Toews, Microsoft Access MVP Please respond only in the newsgroups so that others can read the entire thread of messages. Microsoft Access Links, Hints, Tips & Accounting Systems at http://www.granite.ab.ca/accsmstr.htm Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
JeffG - 27 Jun 2007 13:51 GMT Tom -
You reference your code or Arvin's code to send the PDF file in Outlook....can you elaborate? I've been trying to find out how to send a PDF after using Lebans ReportToPDF, but have been unsuccessful. I want to automate the whole process, with no user intervention or having to attach a file in an email message.
Thanks.
Jeff G
> Hi Samuel, > [quoted text clipped - 29 lines] >> All I want is to send a report with a picture but the picture disappears >> when I use the email option Tony Toews [MVP] - 27 Jun 2007 19:24 GMT >You reference your code or Arvin's code to send the PDF file in >Outlook....can you elaborate? I've been trying to find out how to send a >PDF after using Lebans ReportToPDF, but have been unsuccessful. I want to >automate the whole process, with no user intervention or having to attach a >file in an email message. Microsoft Access Email FAQ http://www.granite.ab.ca/access/email.htm
Tony
 Signature Tony Toews, Microsoft Access MVP Please respond only in the newsgroups so that others can read the entire thread of messages. Microsoft Access Links, Hints, Tips & Accounting Systems at http://www.granite.ab.ca/accsmstr.htm Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Tom Wickerath - 27 Jun 2007 21:50 GMT Hi Jeff,
Take a look at my first reply in this thread, dated 6/24. I provided a link to a zipped Word document, that I call "Access Links.doc". There is a procedure shown on page 17 of this document.
Tom Wickerath Microsoft Access MVP https://mvp.support.microsoft.com/profile/Tom http://www.access.qbuilt.com/html/expert_contributors.html __________________________________________
> Tom - > [quoted text clipped - 7 lines] > > Jeff G JeffG - 28 Jun 2007 14:54 GMT Tom -
That's along the lines of what I want to do, but more specifically, I want to run the ReportToPDF, which generates the PDF, and send the file that was just created without actually saving it to the disk. In your code, it looks like it's using wildcards to send the files. I want to send a single file. The process map would be like:
1. Generate the PDF using ReportToPDF 2. Programmatically set up an email message with that PDF as the attachment, with some items filled in already (i.e. SendTo, Message Body, and attachment). 3. Leave no remnants of the snp or pdf files.
Like I said, I have both the ReportToPDF and your SendMail modules in my database, but can't figure out how to get them to do what I want.
Thanks.
Jeff
> Hi Jeff, > [quoted text clipped - 22 lines] >> >> Jeff G Peter Hibbs - 28 Jun 2007 16:48 GMT Jeff
I have combined the e-mail code from Tom and the ReportToPDF code from Stephen into a single module. You can import the module into your project and then to email a report as a PDF file you can just call a single sub-routine which does everything automatically (in exactly the way you described).
If you would like a copy of the code (providing Tom or Stephen do not object) just email me at peter.hibbs@btinternet.comNOSPAM (leave off the NOSPAM bit) and I will send it on.
Peter Hibbs.
>Tom - > [quoted text clipped - 43 lines] >>> >>> Jeff G Tom Wickerath - 29 Jun 2007 05:42 GMT Hi Peter,
I have no objections, and I'm pretty sure that Stephen would be fine with it too. Thank You for taking this inititive!
Jeff: In your last reply, you wrote: "That's along the lines of what I want to do, but more specifically, I want to run the ReportToPDF, which generates the PDF, and send the file that was just created without actually saving it to the disk."
I don't think this is possible to use the ReportToPDF functionality, without first writing the file to the hard drive, if only as a temporary copy. My code is designed to send files that can be found on the hard drive. One could add code to delete the .pdf file after having sent it, and this would probably be fairly reliable, but, if Access happened to crash for some reason after writing the file, but before the deletion code was run, then you could end up with the .pdf file remaining on the hard drive. Depending on the method that you are using for sending e-mail, you would likely end up with a copy on the hard drive anyways, in the Sent Items folder of Outlook.
You might also want to look into using Win2PDF (http://win2pdf.com). It can be programmed using VBA code. Another Access MVP, who uses this product, is very happy with it.
Tom Wickerath Microsoft Access MVP https://mvp.support.microsoft.com/profile/Tom http://www.access.qbuilt.com/html/expert_contributors.html __________________________________________
> Jeff > [quoted text clipped - 9 lines] > > Peter Hibbs. Tom Wickerath - 29 Jun 2007 05:52 GMT PS. Another possible solution is to use PDF Creator as it is open source and free.
http://sourceforge.net/projects/pdfcreator/
Tom Wickerath Microsoft Access MVP https://mvp.support.microsoft.com/profile/Tom http://www.access.qbuilt.com/html/expert_contributors.html
|
|
|