Avatar of sourcelink
sourcelink

asked on 

Send Access report in Outlook Message Body.


Hello, I am sending an emai message from Access 2003 with an html attachment. (Its a report that was just exported to html).  I would like to include the (report) in the body of the message. Not just an attachment.  it could be rtf, htm or whatever, just as long as the report in inthe body.  The report is not very long. Any help would be greatly appreciated.  Thanks!


  Dim objOutlook As Outlook.Application
  Dim objOutlookMsg As Outlook.MailItem
  Dim objOutlookRecip As Outlook.Recipient
  Dim objOutlookAttach As Outlook.Attachment

  objOutlookAttach = C:\myfile.htm

    Set objOutlook = CreateObject("Outlook.Application")

    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
    Set objOutlookRecip = objOutlookMsg.Recipients.Add(TheAddress)
    objOutlookRecip.Type = olTo

    objOutlookMsg.Subject = (Subject)
    objOutlookMsg.BodyFormat = olFormatHTML
    objOutlookMsg.Body = (MessageBody)   '  Here I want to add the contents of myfile.htm  
    objOutlookMsg.Attachments = AttachmentPath
Microsoft Access

Avatar of undefined
Last Comment
Leigh Purvis
Avatar of EMCIT
EMCIT

Can you reference the text from a field in your form?

 objOutlookMsg.Body = Forms!FormName!TextBoxName
ASKER CERTIFIED SOLUTION
Avatar of Pigster14
Pigster14
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Leigh Purvis
Leigh Purvis
Flag of United Kingdom of Great Britain and Northern Ireland image

So is this just an three part process?

1) Save your report as an html output file.
2) Open the file and grab the source text.
3) Insert the source text into your Outlook email object.
Avatar of Leigh Purvis
Leigh Purvis
Flag of United Kingdom of Great Britain and Northern Ireland image

Of course Pigster's solution is also viable (you could elaborate on it with a few well chosen html tags to format it when inserted into your email.)
I did an example of that type of thing here on EE once... damn I can never remember where... umm...
I'll have a look.
SOLUTION
Avatar of Leigh Purvis
Leigh Purvis
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo