Email a report NOT as an attachment

K

kidkosmo

Hi, all,

I'm wondering if anyone knows a way to send an Access 2007 report as
the body of an email rather than as an attachment. I just created a
report that I will send via email to multiple people on different ISPs
and I'm finding that some ISPs (hotmail and gmail specifically) are
bouncing my emails due to the attachment (if I copy and paste the
report info into the body of an email...no problem).

Thanks!
 
T

Tony Toews [MVP]

kidkosmo said:
I'm wondering if anyone knows a way to send an Access 2007 report as
the body of an email rather than as an attachment. I just created a
report that I will send via email to multiple people on different ISPs
and I'm finding that some ISPs (hotmail and gmail specifically) are
bouncing my emails due to the attachment (if I copy and paste the
report info into the body of an email...no problem).

To create a formatted document to send as an email you will need to
use VBA code to create a largish string. This string will then be
passed to the SendObject command or other method as the body of the
email. For more details including sample air code see my Tips page
on this topic at http://www.granite.ab.ca/access/email/formatted.htm.

Tony
--
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/
 
K

kidkosmo

To create a formatted document  to send as an email you will need to
use VBA code to create a largish string.  This string will then be
passed to the SendObject command or other method as the body of the
email.   For more details including sample air code see my Tips page
on this topic athttp://www.granite.ab.ca/access/email/formatted.htm.

Tony
--
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 athttp://www.granite.ab.ca/accsmstr.htm
   Tony's Microsoft Access Blog -http://msmvps.com/blogs/access/


Wow! Largish is a great word to describe that. On your tips page,
there's a mention of "However given the wide prevalence of email
readers which can read and format HTML bodies using tables and HTML
code is likely a better solution." Since I'm using some sloppy
imported data without much structure (Memo field sometimes with
multiple paragraphs), would using HTML be bit easier to manage? I'm
unfamiliar with HTML and how I might go about doing such a task. I've
checked out Lebans' HTML editor, which kinda makes sense, but I still
don't know how I would pop that into Access to create the emails since
SendObject does not support HTML. Any ideas?

Thanks!!
 
J

Jeff C

--
Jeff C
Live Well .. Be Happy In All You Do


kidkosmo said:
Wow! Largish is a great word to describe that. On your tips page,
there's a mention of "However given the wide prevalence of email
readers which can read and format HTML bodies using tables and HTML
code is likely a better solution." Since I'm using some sloppy
imported data without much structure (Memo field sometimes with
multiple paragraphs), would using HTML be bit easier to manage? I'm
unfamiliar with HTML and how I might go about doing such a task. I've
checked out Lebans' HTML editor, which kinda makes sense, but I still
don't know how I would pop that into Access to create the emails since
SendObject does not support HTML. Any ideas?

Thanks!!

I use the following in Access/Office 2003. The trick is first formatting
your Access report the way you want it as a Text/RTF document. Once in this
format you can place the report in the body of an Outlook message using WORD.

Private Sub SendReport()

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

DoCmd.OutputTo acOutputReport, "ReportName", acFormatRTF,
"FullPathToReport\ReportName.rtf"

Dim wdApp As Word.Application
Dim doc As Word.Document
Dim Report As MailItem

Set wdApp = New Word.Application
Set doc = wdApp.Documents.Open("FullPathToReport\ReportName.rtf")
Set Report = doc.MailEnvelope.Item

Report.To = [Forms]![frm_Request].[txtEmail]
Report.Subject = "Subject"

'Report.Display
'Report.Send
'Set itm = doc.MailEnvelope.Item
'itm.Save
'strID = itm.EntryID
'Set itm = Nothing

Report.Save
strID = Report.EntryID
Set itm = Nothing
Set OL = CreateObject("Outlook.Application")
Set ns = OL.GetNamespace("MAPI")
Set theitem = ns.GetItemFromID(strID)
If Not theitem Is Nothing Then
theitem.Forward.Display
theitem.Delete
End If


wdApp.Quit False
Set doc = Nothing
Set wdApp = Nothing

'DoCmd.Close
'Application.Quit acQuitSaveAll

End Sub


This is code I have behind a simple form which loops through a mail list
sending the report to each particular user. Hope this gives you some ideas
and is of help. You can also research OUTLOOKCode.com.
 
T

Tony Toews [MVP]

kidkosmo said:
Wow! Largish is a great word to describe that.

Yes. The string might end up being 2,000 or 10,000 bytes long. Oh
well, that's life.
On your tips page,
there's a mention of "However given the wide prevalence of email
readers which can read and format HTML bodies using tables and HTML
code is likely a better solution." Since I'm using some sloppy
imported data without much structure (Memo field sometimes with
multiple paragraphs), would using HTML be bit easier to manage?

No, HTML would make this a lot more work as you would either have to
merge with an HTML editor as you point out or insert the raw HTML code
in the string as well. Which I've done in the past.
I'm
unfamiliar with HTML and how I might go about doing such a task.

Format an email to your preference and email it to yourself. Then
your email program should give you the capability of viewing the
source. Now copy that HTML code into Access somehow to use. Or you
may want to put the HTML code into a memo field and do some find and
replaces to change "parameters" to values. That is embed %1% which
means parameter 1 and do InStr and Mid to concatenate data.
I've
checked out Lebans' HTML editor, which kinda makes sense, but I still
don't know how I would pop that into Access to create the emails since
SendObject does not support HTML. Any ideas?

You have to use the email software's method of using HTML. Outlook
has such a parameter. HTMLBody if I recall correctly. But as you
point out SendObject does not.

Tony
--
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/
 
G

Guest

GRACIAS:SIN LUGAR A DUDAS ERROR DE (MI PARTE)

Tony Toews said:
Yes. The string might end up being 2,000 or 10,000 bytes long. Oh
well, that's life.


No, HTML would make this a lot more work as you would either have to
merge with an HTML editor as you point out or insert the raw HTML code
in the string as well. Which I've done in the past.


Format an email to your preference and email it to yourself. Then
your email program should give you the capability of viewing the
source. Now copy that HTML code into Access somehow to use. Or you
may want to put the HTML code into a memo field and do some find and
replaces to change "parameters" to values. That is embed %1% which
means parameter 1 and do InStr and Mid to concatenate data.


You have to use the email software's method of using HTML. Outlook
has such a parameter. HTMLBody if I recall correctly. But as you
point out SendObject does not.

Tony
--
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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top