Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email access Report

Status
Not open for further replies.

dinster

Programmer
Apr 12, 2007
54
GB
Hi everyone....

Is there way by code to email a report. I create temporary table which the reports uses in access database.

Could some1 give me an example or something to get me started...i dont want to save the report...i just want my vb.net (2003) application by a command button... to got to rptDischargeSummary and email it?

i've got this far...but dont know how to email the report... which is in access database
Code:
    Function EmailFile()
        'Step 4: Emails summary to coding department
        Dim olapp As New Outlook.Application
        Dim ol As Outlook._MailItem
        Dim body As String

        body = Chr(13) & Chr(13) & "Dear Coding Department" & Chr(13) & Chr(13)
        body = body & "Please find attached the ICU Discharge Summary data for :" & Chr(13) & Chr(13)
        body = body & "Patient Name : " & txtName.Text & "" & Chr(13)
        body = body & "Hospital Number : " & mrn & "" & Chr(13)
        body = body & "ICU Reference : " & pid & "" & Chr(13) & Chr(13)
        body = body & "Any problems, please contact ICU on Ext 82268" & Chr(13) & Chr(13)
        body = body & "Karen Franklin" & Chr(13)
        body = body & "Intensive Care Department" & Chr(13)
        body = body & "First Floor, East Wing 1" & Chr(13)
        body = body & "Ext 82268"

        'test.Session.Logon()

        ol = olapp.CreateItem(Outlook.OlItemType.olMailItem)
        ol.To = CodingEmailAddress
        ol.Subject = "ICU Discharge Summary (Hosp Number =  " & mrn & ")"
        ol.Body = body

        ol.OriginatorDeliveryReportRequested = False
        ol.Save()
        ol.Send()
        ol = Nothing

        'test.Session.Logoff()
        olapp = Nothing

    End Function

many thanks
 
Well, if you want to send the report as an attachment, it needs to be saved as a file that can be attached. No file = no attachment. However, that does not mean that you have to keep the file around after the email is sent. I do this frequently - I have an app that has to send an email with a program-generated Word document attached. I generate the Word file, save it, send the email with the Word file attached, then finally delete the Word file. This works quite well.

As to how to save the Access report to a file that you can attach, I have no idea.



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top