Full Version: Exporting a Report to Word file to e-mail
UtterAccess Discussion Forums > Microsoft® Access > Access Reports
quest4
Good afternoon, I am trying to have a report save to a file that can be opened after it is e-mail to someone. I have tried several types in Output To, like snapshot and rich text and HTML, but they all want me to select a program to open them and so they are no good. Is there a way that I could export the report to Word and be saved as a file in My Documents? I figure that way I can then compress it and send it and it will open easily. I am using Access2000 with Windows XP Pro. My mail, if it is important, would be Roadrunner Web Mail. An thoughts or ideas here will be deeply appreciated. Thank you in advance for any assistance.
theDBguy
Have you tried using the SendObject method?
quest4
Thanks for the reply and as I stated yes I have and I have problems opening the saved document, as I stated, snapshot won't open and rich tex and html don't know what to open with. Rich text looks great if you tell it to use Word. The people who will be using this have very littel computer knowledge so the more automated the better. I do have a DAO procedure for doing this thruogh Outlook and and our mail sever, but this is going to be through and ISP and so I will try to get this to do as much as I can. Thanks again.
HiTechCoach
That may not be Access issue but a Windows file association issue. Are you sure that the file name has the correct extension ( .snp, .rtf, or .htm)
o you have the snapshot viewer installed to view a snapshot file ( .snp extension)?
How are you trying to open the file? Are you just double-clicking on it in Explorer? If not try this to verify the file association is correct.
Are you trying to open the file with VBA code? If yes, then what code are you using?
quest4
Thanks again for the response. I just tried that SendObject with a snapshot and I recieved it in my e-mail and it opened alright. But this is going to be done on an different computer and there is no Outlook on that one, but there is roadrunner web mail and that is why I kind of looked at creating a file to e-mail. I am not sure how to get this into RR's web mail. It would be great if I could use it. Thanks.
theDBguy
Sorry I missed that detail earlier...
When using the OutputTo method, are you doing something like:
DoCmd.OutputTo acOutputReport, "yourreport", acFormatSNP, "c:\documents and settings\yourprofile\my documents\report.snp"
Hope that helps...
quest4
Thanks again for the response, theDBug. I think I have read too much code, but where wouold I put that code? Currently I am using a macro to print the report and then something like send object and then a quick select query to clean up things. Thanks again.
theDBguy
If I understand you correctly, you cannot use SendObject because you have no mail client installed on the machine, that's why you had to use web mail.
If you want to use a macro, use the OutputTo Action and put the location where you want to save the file in the proper parameter/argument for the command.
Hope that helps...
HiTechCoach
You probably can use SMTP to send the email. I use it with ISP's that offer web based emaill.
omething like:
CODE
' SEND EMAIL VIA SMTP USING CDOEX/CDOSYS
Sub prcSendMail(pstrFrom,pstrTo,pstrCC,pstrBCC,pstrSubject,pstrBody)
  Const cstrSMTPServer = "NAMEOFYOURSMTPSERVER"
  Const cintCDOSendUsingPort = 2
  Dim objConfig, objMsg
  If (Len(pstrFrom & "") > 0) And (Len(pstrTo & "") > 0) And (Len(pstrSubject & "") > 0) And (Len(pstrBody & "") > 0) Then
    Set objConfig = CreateObject("CDO.Configuration")
    objConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cintCDOSendUsingPort
    objConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = cstrSMTPServer
    objConfig.Fields.Update
    Set objMsg = CreateObject("CDO.Message")
    Set objMsg.Configuration = objConfig
    objMsg.From = pstrFrom
    objMsg.To = pstrTo
    If Len(pstrCC & "") > 0 Then objMsg.CC = pstrCC
    If Len(pstrBCC & "") > 0 Then objMsg.BCC = pstrBCC
    objMsg.Subject = pstrSubject
    objMsg.HTMLBody = pstrBody
    objMsg.Send
    Set objMsg = Nothing
    Set objConfig = Nothing
  End If
End Sub

Hope this helps ...
quest4
Thanks you HiTech for that response, you seem to understand what I am trying to do. I do have one last dumb question, do I put this in as a modual or as a sub in the report. Basically where am I putting this? Thanks again for the help and do I have to turn on any references? Thanks again for all of the help.
quest4
I do now have a couple of questions, first do I find of the name of my sMTP Server? Is the the PC that will have the dbase on it? Where do i put the e-mail address? Where do I put the from? I looking at this I really don't see a format like snapshot. And one last thing, do I put this in as a module and in the macro use run code or just how do I do this? thanks again for the help.
quest4
Oh another dumb question, with the SMTP server, do I want the IP address or the name? Thanks again.
theDBguy
I'm not sure if an IP address will work, but the name of your RoadRunner SMTP Server will definitely work.
Hope that helps...
teabags
Hello,
copied your sub in to my module.
Private Sub cmdSend_Click()
prcSendMail
End Sub
But I get arguement not optional error (using access 2003).
Any ideas where I am going wrong?
Thank you.
theDBguy
Hi teabags,
On case HiTechCoach is not watching this thread...
The proper use of that function is something like:
Private Sub cmdSend_Click()
prcSendMail "FromAddress", "ToAddress", "CCAddress", "BCCAddress", "Subject", "EmailBody"
End Sub
Hope that helps...
teabags
Hello,
I forgot that I had to pass arguements in the brackets.
Thank you.
theDBguy
Hi,
We all make mistakes some times. Good luck with your project.
richard93312
I am looking at the code and I don't see where the user name and password is authenticated. Did I miss something?
theDBguy
Hi Richard,
heck out this link for the additional steps to include authentication.
Hope that helps...
richard93312
Thank you. Now sending email with attachments via SMTP.
theDBguy
Hi Richard,
Congratulations! Glad to hear you're up and running now. Good luck with your project.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.